【发布时间】:2013-09-09 10:25:45
【问题描述】:
我正在尝试使用 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 上,我的日志中出现以下错误:
JavaScript 错误 (UnexpectedJavaScriptError) 在 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.DefaultWait1.Until[TResult](Func`2 条件)在 c:\Projects\WebDriver\trunk\dotnet\src\WebDriver.Support\UI\DefaultWait.cs:line 180 在 MainClass.waitForPageToLoad()
我不知道为什么会这样。 有人可以帮我吗?
真诚地, 亚当。
【问题讨论】:
-
记录整个异常,如日志
e.ToString(),而不仅仅是消息并将堆栈跟踪连接到它。这是什么版本的IE?你能在 IE 的开发者控制台上运行那个 javascript 吗?
标签: c# internet-explorer exception selenium