Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.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# “硒例外”;在关闭的窗口中找不到元素;使用IE11_C#_Internet Explorer_Selenium_Selenium Webdriver - Fatal编程技术网

C# “硒例外”;在关闭的窗口中找不到元素;使用IE11

C# “硒例外”;在关闭的窗口中找不到元素;使用IE11,c#,internet-explorer,selenium,selenium-webdriver,C#,Internet Explorer,Selenium,Selenium Webdriver,当我运行简单的selenium测试用例时,我得到了“无法在关闭的窗口中找到元素” 当我运行代码时会发生什么? 当我运行代码时,首先发生的是一个控制台打开,它告诉我 “已启动InternetExplorerDriver服务器(64位)2.42.0.0” 第二种情况是IE 11以文本开始 “这是WebDriver服务器的初始起始页。” 第三种情况是www.google.com被加载并显示在同一个web浏览器中 现在,测试用例正在等待查找元素q,但它找不到q元素。所以测试用例超时了 但是为什么sele

当我运行简单的selenium测试用例时,我得到了“无法在关闭的窗口中找到元素”

当我运行代码时会发生什么? 当我运行代码时,首先发生的是一个控制台打开,它告诉我 “已启动InternetExplorerDriver服务器(64位)2.42.0.0”

第二种情况是IE 11以文本开始
“这是WebDriver服务器的初始起始页。”

第三种情况是www.google.com被加载并显示在同一个web浏览器中

现在,测试用例正在等待查找元素q,但它找不到q元素。所以测试用例超时了

但是为什么selenium找不到元素,网页可以加载,我可以看到搜索字段。 我已经研究这个问题很久了,现在开始有点暴躁 我做错了什么,我错过了什么?
我使用VS 2013

仅使用32位版本的驱动程序,并查看文档:为使驱动程序有机会与IE11通信,需要进行额外设置。另外,不要使用谷歌。什么都可以,除了谷歌。谢谢阿伦,有时候我会失明。
IWebDriver driver = new   InternetExplorerDriver(@"C:\Development\Drivers\IEDriverServer_x64_2.42.0");
driver.Navigate().GoToUrl("http://www.google.com");

var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
wait.Until(ExpectedConditions.ElementExists(By.Name("q")));

IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Selenium");
query.Submit();

wait.Until((d) => { return d.Title.ToLower().StartsWith("Selenium");});
driver.Quit();