简体   繁体   English

硒和Internet Explorer驱动程序

[英]Selenium and Internet Explorer Driver

I'm trying to run some tests with C# and InternetExplorerDriver. 我正在尝试使用C#和InternetExplorerDriver运行一些测试。

This code is executed on Windows Server 2012, 64 bit. 此代码在Windows Server 2012 64位上执行。

Right after navigation to a new URL, I'm calling a function that waits until a page loads\\20 seconds timeout. 导航到新URL之后,我正在调用一个函数,该函数等待页面加载\\ 20秒超时。

private bool waitForPageToLoad()
    {
        try
        {
            int timeout = int.Parse(ConfigurationManager.AppSettings["TimeoutForCustomExpression"]);
            IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(m_driver, TimeSpan.FromSeconds(timeout));

            wait.Until(driver1 => ((IJavaScriptExecutor)m_driver).ExecuteScript("return document.readyState").Equals("complete"));
        }
        catch//(Exception e) //timeout
        {
            log(e.Message + e.StackTrace);
            return false;
        }
        return true;
    }

The function works great for every browser other than IE. 该功能适用​​于除IE之外的所有浏览器。

On IE, I the following error in my log: 在IE上,我在日志中出现以下错误:

JavaScript error (UnexpectedJavaScriptError) at OpenQA.Selenium.Support.UI.DefaultWait 1.PropagateExceptionIfNotIgnored(Exception e) in c:\\Projects\\WebDriver\\trunk\\dotnet\\src\\WebDriver.Support\\UI\\DefaultWait.cs:line 222 at OpenQA.Selenium.Support.UI.DefaultWait 1.Until[TResult](Func`2 condition) in c:\\Projects\\WebDriver\\trunk\\dotnet\\src\\WebDriver.Support\\UI\\DefaultWait.cs:line 180 at MainClass.waitForPageToLoad() OpenQA.Selenium.Support.UI.DefaultWait上的JavaScript错误(UnexpectedJavaScriptError)1 1.PropagateExceptionIfNotIgnored(Exception e) in c:\\Projects\\WebDriver\\trunk\\dotnet\\src\\WebDriver.Support\\UI\\DefaultWait.cs:line 222 at OpenQA.Selenium.Support.UI.DefaultWait 1. 1.PropagateExceptionIfNotIgnored(Exception e) in c:\\Projects\\WebDriver\\trunk\\dotnet\\src\\WebDriver.Support\\UI\\DefaultWait.cs:line 222 at OpenQA.Selenium.Support.UI.DefaultWait MainClass.waitForPageToLoad的c:\\ Projects \\ WebDriver \\ trunk \\ dotnet \\ src \\ WebDriver.Support \\ UI \\ DefaultWait.cs:line 180中的[TResult](Func`2条件) ()

I have no idea why it happens. 我不知道为什么会这样。 Could somebody help me out here? 有人可以帮我吗?

Sincerely, Adam. 真诚的亚当。

Without seeing all that extra information that Arran requested, it's hard to help you understand the error. 没有看到Arran要求的所有其他信息,很难帮助您理解该错误。 However if you're just looking for a quick fix that works in all browsers, I always just use Thread.sleep(int milliseconds); 但是,如果您只是想寻找一种适用于所有浏览器的快速修复程序,我总是只使用Thread.sleep(int milliseconds); for my Selenium tests in C# that need to wait for a page to load or a certain element to render before continuing. 对于我在C#中进行的Selenium测试,需要等待页面加载或某个元素呈现后才能继续。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在私有模式下运行Internet Explorer Selenium Web驱动程序C# - Running Internet Explorer selenium web driver in private mode c# Selenium Internet Explorer驱动程序,Kendo Mobile和Octopus Deploy - Selenium Internet Explorer Driver, Kendo Mobile and Octopus Deploy 为什么 Selenium 的 Internet Explorer 驱动程序偶尔无法保持与 Web 驱动程序服务器的连接? - Why does Selenium's Internet Explorer Driver occasionally fail to keep the connection to the Web Driver Server alive? 如何使用C#中的AutoIT库在具有硒驱动程序的Internet Explorer中下载文件? - How to Download file in Internet Explorer with selenium driver using AutoIT library in C#? Selenium - Visual Studios- C# - 所有(chrome、firefox 和 Internet Explorer)webdrivers 无法启动驱动程序服务 - Selenium - Visual Studios- C# - All (chrome, firefox, and internet explorer) webdrivers unable to start driver service Selenium c#:如何在特定版本中启动Internet Explorer驱动程序(例如IE8) - Selenium c#: How to launch Internet Explorer driver in a specific version (IE8 for example) 在Internet Explorer中一起使用Selenium和LeanFT - Using Selenium and LeanFT together in Internet Explorer 使用Selenium以其他用户身份运行Internet Explorer - Run internet explorer as different user using Selenium Selenium grid 2 Internet Explorer真的很慢 - Selenium grid 2 internet explorer is really slow 硒; 无法在Internet Explorer中按类查找元素 - Selenium; Unable to find element by class in Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM