更新:
在更新到它的类似情况后,我遇到了同样的问题,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)