nel*_*ziq 13 internet-explorer selenium-webdriver
无论使用的页面或选择类型如何,我都无法通过Internet Explorer驱动程序识别Selenium.
String iedriver = "C:\\selenium-server\\IEDriverServer.exe";
System.setProperty("webdriver.ie.driver", iedriver);
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.xpath("//body"));
Run Code Online (Sandbox Code Playgroud)
通过xpath选择给出了 org.openqa.selenium.InvalidSelectorException:无法在WebElement中评估xpath表达式'// body'.其他选择类型也会失败:
WebElement element = driver.findElement(By.cssSelector("body"));
Run Code Online (Sandbox Code Playgroud)
要么
WebElement element = driver.findElement(By.tagName("body"));
Run Code Online (Sandbox Code Playgroud)
要么
WebElement element = driver.findElement(By.name("q"));
Run Code Online (Sandbox Code Playgroud)
通过CSS选择器,名称或标签名称始终导致 org.openqa.selenium.NoSuchElementException
使用Firefox驱动程序,Chrome驱动程序甚至Html单元驱动程序,所有选项都可以正常运行.
浏览器正确启动,页面按预期加载. driver.getCurrentUrl(); 和driver.getPageSource(); 返回预期值.
我尝试在选择元素之前引入显式和隐式等待,但是没有效果,使用
Thread.sleep(10000);
Run Code Online (Sandbox Code Playgroud)
要么
WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//body")));
Run Code Online (Sandbox Code Playgroud)
还尝试单步执行代码以手动等待元素显示.
我尝试过的其他事项包括1)在所有区域中将安全设置设置为相同级别2)禁用增强保护模式3)在注册表中设置FEATURE_BFCACHE
我使用的是Selenium和IEDriverServer版本2.41.观察到本地和远程运行的问题.环境在Windows 7 64位上使用IE10 64位和IEDriverServer 64位.使用IEDriverServer 32位在IE11 32位上观察到同样的问题.我在这里使用www.google.com作为可公开查看的测试,但在我们的内部网站上也观察到了这个问题.
Pun*_*660 16
对于那些在IE11上遇到问题的人,原因如下:微软通过Windows Update [1]发布更新KB3025390作为其正常"补丁星期二"更新周期的一部分.对于大多数用户,无需用户交互即可下载和安装此更新.与IE11一起使用时,此更新会破坏IE驱动程序.
https://groups.google.com/forum/m/#!topic/selenium-users/TdY_rRNF-gw
修复,删除更新.目前没有Selenium更新来解决此问题.
小智 7
对我有用的是本页底部提到的解决方案:运行本地HTML页面
要解决此问题,请转到"工具"菜单中的"Internet选项"(或更新版本中的齿轮图标).打开"高级"选项卡.向下滚动到"安全"并选择"允许活动内容在我的计算机上的文件中运行".
然后需要重新启动.
| 归档时间: |
|
| 查看次数: |
41107 次 |
| 最近记录: |