Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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
Selenium InvalidArgumentException EnsureCleanseSession是已知的IEDriverServer 3.12.0问题,还是我对它的实例化不正确?_Selenium_Selenium Webdriver_Webdriver_Iedriverserver - Fatal编程技术网

Selenium InvalidArgumentException EnsureCleanseSession是已知的IEDriverServer 3.12.0问题,还是我对它的实例化不正确?

Selenium InvalidArgumentException EnsureCleanseSession是已知的IEDriverServer 3.12.0问题,还是我对它的实例化不正确?,selenium,selenium-webdriver,webdriver,iedriverserver,Selenium,Selenium Webdriver,Webdriver,Iedriverserver,当我尝试像这样实例化IEDriverServer 3.12.0时: import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; public class StartInternetExplorer { public static void main(String[] args) { // Add to Windows PATH variable:

当我尝试像这样实例化IEDriverServer 3.12.0时:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class StartInternetExplorer {
    public static void main(String[] args) {
        // Add to Windows PATH variable: C:\IEDriverServer_Win32_3.12.0\;
        String executable = "C:\\IEDriverServer_Win32_3.12.0\\IEDriverServer.exe";
        System.setProperty("webdriver.ie.driver", executable);
        WebDriver driver = new InternetExplorerDriver();
        driver.get("https://www.google.com");
        driver.quit();
    }
}
我看到这个异常堆栈跟踪:

Started InternetExplorerDriver server (32-bit)
3.12.0.0
Listening on port 46039
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: All firstMatch elements failed validation
Invalid capabilities in firstMatch element 0: unknown capability named ensureCleanSession
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'XXXXXXXX', ip: '127.0.0.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
remote stacktrace: 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
    at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:215)
    at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:152)
    at app.StartInternetExplorer.main(StartInternetExplorer.java:11)
已启动InternetExplorerDriver服务器(32位)
3.12.0.0
正在侦听端口46039
只允许本地连接
线程“main”org.openqa.selenium.InvalidArgumentException中出现异常:所有firstMatch元素验证失败
firstMatch元素0中的功能无效:名为ensureCleanSession的未知功能
构建信息:版本:“3.12.0”,修订版:“7c6e0b3”,时间:“2018-05-08T14:04:26.12Z”
系统信息:主机:'XXXXXXXX',ip:'127.0.0.1',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_161'
驱动程序信息:Driver.version:InternetExplorerDriver
远程堆栈跟踪:
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:423)
位于org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
位于org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
位于org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
位于java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
位于java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
位于java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
位于java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
位于java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
位于java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
位于java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
位于java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
位于java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
位于org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
位于org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
位于org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
位于org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
位于org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
位于org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
位于org.openqa.selenium.ie.InternetExplorerDriver(InternetExplorerDriver.java:215)
位于org.openqa.selenium.ie.InternetExplorerDriver(InternetExplorerDriver.java:152)
位于app.startinternetxplorer.main(startinternetxplorer.java:11)

我不知道“ensureCleanSession”参数来自何处,所以我不知道这是否意味着3.12.0中存在漏洞,或者我没有正确实例化IEDriverServer。

尝试在URL中传递4个斜杠,结果成功。似乎他们在selenium API中做了一些更改,但我不确定。这对我很有用:

import org.openqa.selenium.ie.InternetExplorerDriver;

public class Money {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Hello World");
        System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
        InternetExplorerDriver driver=new InternetExplorerDriver();
        driver.get("https:\\\\www.google.com");
    }
}

我无法在3.14.0版中复制这一点-解决方案是等待新版本

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class StartInternetExplorer {
    public static void main(String[] args) {
        // Add to Windows PATH variable: C:\IEDriverServer_Win32_3.14.0\;
        String executable = "C:\\IEDriverServer_Win32_3.14.0\\IEDriverServer.exe";
        System.setProperty("webdriver.ie.driver", executable);
        WebDriver driver = new InternetExplorerDriver();
        driver.get("https://www.google.com");
        driver.quit();
    }
}

如果这确实代表了您启动IE驱动程序的代码,那么是的,某个地方有一个bug。另一方面,如果您的框架试图将功能传递给某个地方的驱动程序构造函数(例如,
caps.setCapability(“EnsureLeanSession”,true);
),那么不,这不是错误,因为这对IE驱动程序来说不是有效的功能。它适用于其他实现,但W3C WebDriver规范允许驱动程序拒绝未知功能,而版本3.5之后的IE驱动程序会拒绝未知功能。