Selenium调用IE出错SessionNotCreatedException

从头到尾看了几遍官方文档,也把IEDriverServer.exe加入了PATH,也试过

File file = new File("C:\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());

这样加载,代码就一句:

public class Test {
    public static void main(String[] args) {
        WebDriver driver = new InternetExplorerDriver();
    }
}

但是报错

Listening on port 30697
Only local connections are allowed
十月 20, 2016 3:33:31 下午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
十月 20, 2016 3:33:32 下午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Falling back to original OSS JSON Wire Protocol.
十月 20, 2016 3:33:32 下午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Falling back to straight W3C remote end connection
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'WIN-3DLUDLJN43H', ip: '10.0.2.15', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: InternetExplorerDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
    at Fuck.main(Fuck.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Process finished with exit code 1

试了很多windows版本和IE版本,selenium3.0和3.0.1都试了,java8环境64位,快疯了跪求大神

阅读 11.1k
5 个回答

谢邀。

java的我没玩过,我都是玩python的。但是一般出现问题都是版本匹配上的问题。你可以试试其他浏览器,比如 firefox

传送门:http://www.cnblogs.com/pureso...

抱歉,java我不会用!

你没配置文件

新手上路,请多包涵

看一下 你的host

clipboard.png

添加后好使不

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题