Selenium WebDriver 的新手,试图让我的 firefox/chrome 脚本在 IE 中运行,但它似乎无法找到任何元素。
例如,这是我用来启动 IE 网络驱动程序的代码去谷歌搜索世界“等等”
driver = new InternetExplorerDriver(@"C:\Program Files (x86)\IEdriver");
driver.Navigate().GoToUrl("http://www.google.com");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
IWebElement search = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Name("q"));
});
search.SendKeys("Blah");
结果:Google 加载然后测试失败并出现“NoSuchElementException” - 无法找到名称为 ==q 的元素
这在 Firefox 和 Chrome 中运行良好。
*使用 Visual Studio Ultimate C# 和 NUnit
谢谢,丽兹