java – Selenium – NoSuchWindowException in IE 11

栏目: 编程工具 · 发布时间: 7年前

内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/24746777/selenium-nosuchwindowexception-in-ie-11

我试图在IE11中使用selenium自动化网页.我将保护模式设置设置为相同级别,缩放级别为100%.在运行测试时,它打开网站,但是给出了异常.以下是使用的代码.

File file = new File("C:\\Users\\Desktop\\IEDriverServer.exe");
   System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );       
   DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
   capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
   true); 
   WebDriver driver = new InternetExplorerDriver(capabilities);
   driver.get("http://www.google.com");

并且异常stacktrace

Started InternetExplorerDriver server (32-bit)
2.39.0.0
Listening on port 38122
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused        connection abort: recv failed
Jul 11, 2014 1:50:02 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Unable to find element on   closed window (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 18 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
 System info: host: 'Neeraj', ip: '10.136.180.161', os.name: 'Windows 7',  s.arch: 'amd64',      os.version: '6.1', java.version: '1.7.0_60'  Session ID: ab6edd65-8a66-41fa-be46-56fba7dbdfc9
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
 Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0,                          ignoreZoomSetting=false,                                  enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true,   unexpectedAlertBehaviour=dismiss, version=11, ie.usePerProcessProxy=false, cssSelectorsEnabled=true,   ignoreProtectedModeSettings=true, requireWindowFocus=false,  handlesAlerts=true, initialBrowserUrl=http://localhost:38122/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
 at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
 at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
 at org.openqa.selenium.By$ById.findElement(By.java:220)
 at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
 at Test1.main(Test1.java:27)

关于如何解决这个问题的任何建议.

首先,不要使用

capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

因为您已经设置了保护模式设置.对于您所看到的问题,应该是因为缺少的注册表设置被添加为在IE11中运行测试的先决条件:

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

代码日志版权声明:

翻译自:http://stackoverflow.com/questions/24746777/selenium-nosuchwindowexception-in-ie-11


以上所述就是小编给大家介绍的《java – Selenium – NoSuchWindowException in IE 11》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

概率编程实战

概率编程实战

[美]艾维·费弗 (Avi Pfeffer) / 姚军 / 人民邮电出版社 / 2017-4 / 89

概率推理是不确定性条件下做出决策的重要方法,在许多领域都已经得到了广泛的应用。概率编程充分结合了概率推理模型和现代计算机编程语言,使这一方法的实施更加简便,现已在许多领域(包括炙手可热的机器学习)中崭露头角,各种概率编程系统也如雨后春笋般出现。本书的作者Avi Pfeffer正是主流概率编程系统Figaro的首席开发者,他以详尽的实例、清晰易懂的解说引领读者进入这一过去令人望而生畏的领域。通读本书......一起来看看 《概率编程实战》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

MD5 加密
MD5 加密

MD5 加密工具

SHA 加密
SHA 加密

SHA 加密工具