Selenium 面对windows 10上IE 11的问题,浏览器已启动,但未输入URL

Selenium 面对windows 10上IE 11的问题,浏览器已启动,但未输入URL,selenium,selenium-webdriver,selenium-iedriver,Selenium,Selenium Webdriver,Selenium Iedriver,硒代码: System.setProperty("webdriver.ie.driver","D:\\Automation\\Drivers\\IEDriverServer.exe"); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability("ignoreZoomSetting", true); WebDriver driver = new Int

硒代码:

System.setProperty("webdriver.ie.driver","D:\\Automation\\Drivers\\IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("ignoreZoomSetting", true);
WebDriver driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Thread.sleep(3000);
driver.get("http://google.co.in");
错误:

Started InternetExplorerDriver server (64-bit)
3.8.0.0
Listening on port 25160
Only local connections are allowed
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: session null does not exist (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'TS-39', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'

错误说明了一切:

org.openqa.selenium.remote.SessionNotFoundException: session null does not exist
原因 您看到SessionNotFoundException的主要原因是由于以下原因:

  • 您正在使用InternetExplorerDriver版本3.8.0.0,从下面的日志中可以明显看出,该版本已正确启动

    Started InternetExplorerDriver server (64-bit)
    3.8.0.0
    Listening on port 25160
    Only local connections are allowed
    
  • 但是您的
    Selenium
    版本是2.53.1,这从下面的日志中可以明显看出:

    Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
    
    System info: host: 'TS-39', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
    
  • 此外,您的JDK版本比1.8.0_91版本旧得多,这从下面的日志中可以明显看出:

    Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
    
    System info: host: 'TS-39', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
    
解决方案 简单的解决办法是:

  • 将您的JDK版本更新到当前级别JDK(JavaSE9.0.1)
  • 将您的Selenium Java客户端版本更新到当前级别v3.8.1
  • 将您的InternetExplorerDriver版本更新到当前级别v3.8.0.0
  • 执行
    测试

每当浏览器启动但未输入URL时,您首先要做的是确保您的Selenium驱动程序和浏览器是最新的(或者如果您有意降级,则至少是匹配的版本)。