[英]Running Internet Explorer selenium web driver in private mode c#
[英]Selenium and Internet Explorer Driver
我正在尝试使用C#和InternetExplorerDriver运行一些测试。
此代码在Windows Server 2012 64位上执行。
导航到新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;
}
该功能适用于除IE之外的所有浏览器。
在IE上,我在日志中出现以下错误:
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条件) ()
我不知道为什么会这样。 有人可以帮我吗?
真诚的亚当。
没有看到Arran要求的所有其他信息,很难帮助您理解该错误。 但是,如果您只是想寻找一种适用于所有浏览器的快速修复程序,我总是只使用Thread.sleep(int milliseconds);
对于我在C#中进行的Selenium测试,需要等待页面加载或某个元素呈现后才能继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.