【发布时间】:2013-03-15 05:05:36
【问题描述】:
更新:
我在更新到 2.29 后遇到了同样的问题,它的前后不一致是令人沮丧的部分。
更新结束:
Selenium WebDriver 2.25 版本。 浏览器:FF(17.0.1版本)&IE(8)
最烦人/让我发疯的一件事是关于过时的元素,我仍然不确定我的测试用例如何一直运行通过;有时我的测试用例通过,有时失败,我正在使用 CSSSelector 查找元素,但我的测试用例仍然开/关失败....
这是我用来查找元素的内容。
这是我的 C# 代码
public class WebDriverUtil
{
public static IWebDriver driver = StartBrowser();
private static FirefoxProfile _ffp;
private static IWebDriver _driver;
private static IWebDriver StartBrowser()
{
switch (Common.BrowserSelected)
{
case "ff":
_ffp = new FirefoxProfile();
_ffp.AcceptUntrustedCertificates = true;
_driver = new FirefoxDriver(_ffp);
break;
case "ie":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
_driver = new InternetExplorerDriver(options);
_driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(2));
break;
case "chrome":
//_driver = new ChromeDriver();
break;
}
return _driver;
}
public static IWebElement WaitForElement(By by)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
return wait.Until(drv => drv.FindElement(by));
}
}
public class TestCaseEmployee: WebDriverUtil
{
public static bool EmployeeCase()
{
//....
WaitForElement(By.LinkText("Select All Employee")).Click(); //<<< see error below
}
}
//错误信息:
Test 'M:TestCases.TestCaseEmployee' failed: No response from server for url http://localhost:7056/hub/session/79b742cf-e1dc-4016-bdbb-c2de93cd8fa4/element
OpenQA.Selenium.WebDriverException: No response from server for url http://localhost:7056/hub/session/79b742cf-e1dc-4016-bdbb-c2de93cd8fa4/element
at OpenQA.Selenium.Support.UI.DefaultWait`1.PropagateExceptionIfNotIgnored(Exception e)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
【问题讨论】:
-
提及您在哪个浏览器中收到此错误并提供详细信息。
-
你为什么运行旧版本的 Selenium?什么版本的 IE & FF?
-
FF(17.0.1版本)&IE(8)
-
不,不是,它是
v2.29.1: code.google.com/p/selenium/downloads/list ....考虑到 FF 17 support 直到v2.27才出现,至少升级您的 Selenium 版本并重试。这包括both 绑定和 IE 驱动程序,自v2.25以来它已经有了一些改进。 -
不要使用主网站,我给你的上面的链接是指向源代码存储库的直接链接——它保持最新,而网站不是。不,最新的 .NET 版本是
2.29.1。