Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Selenium Internet Explorer WebDriver NoTouchElement异常_C#_Internet Explorer_Selenium_Nosuchelementexception - Fatal编程技术网

C# Selenium Internet Explorer WebDriver NoTouchElement异常

C# Selenium Internet Explorer WebDriver NoTouchElement异常,c#,internet-explorer,selenium,nosuchelementexception,C#,Internet Explorer,Selenium,Nosuchelementexception,SeleniumWebDriver新手,尝试让我的firefox/chrome脚本在IE中工作,但它似乎找不到任何元素 例如,下面是我用来启动IE webdriver的代码,转到谷歌搜索世界“废话” driver = new InternetExplorerDriver(@"C:\Program Files (x86)\IEdriver"); driver.Navigate().GoToUrl("http://www.google.com");

SeleniumWebDriver新手,尝试让我的firefox/chrome脚本在IE中工作,但它似乎找不到任何元素

例如,下面是我用来启动IE webdriver的代码,转到谷歌搜索世界“废话”

        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");
driver=newinternetexplorerdriver(@“C:\ProgramFiles(x86)\IEdriver”);
driver.Navigate().gotour(“http://www.google.com");
WebDriverWait wait=新的WebDriverWait(驱动程序,TimeSpan.FromSeconds(20));
IWebElement搜索=等待。直到((d)=>
{
返回d.FindElement(按名称(“q”);
});
search.SendKeys(“废话”);
结果:Google加载然后测试失败,出现“NoTouchElementException”-找不到名为==q的元素

这在firefox和Chrome中运行良好

*使用Visual Studio Ultimate C#和NUnit

谢谢,
丽兹

它会等20秒吗?您是否正确设置了保护模式设置?什么版本的硒?什么版本的我?我还建议你不要使用谷歌,它对于“起始页”来说太复杂了。是的,它要等20秒才会超时,selenium版本2.39。谷歌很抱歉,仅以它为例。@user3380737您使用的是什么版本的IE?WebDriver尚未正式支持IE 11,请尝试使用旧版本的IE,阅读有关IEDriver的更多详细信息。我切换到Internet Explorer 10并运行了测试。没有变化。