org.openqa.selenium.SessionNotCreatedException:无法找到与 Selenium v3.14.0 和 GeckoDriver v0.23.0 匹配的一组功能
org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities with Selenium v3.14.0 and GeckoDriver v0.23.0
我的版本是selenium-java-3.14.0和geckodriver-v0.23.0-win64。
我正在使用以下代码。
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\\Try out files\\geckodriver.exe");
driver = new FirefoxDriver();
String baseURL = "http://www.google.com";
driver.get(baseURL);
当我 运行 它时,我收到以下错误消息。
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: '*******', ip: '*****`enter code here`', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
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.W3CHandshakeResponse.lambda$new[=12=](W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession[=12=](ProtocolHandshake.java:122)
at java.util.stream.ReferencePipeline.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
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:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
at basicweb.FirefoxDriverDemo.main(FirefoxDriverDemo.java:17)
使用 firefox 版本 56 或 61 和 gecko 驱动程序版本 0.21。并添加 firefox 选项使用配置文件。
FirefoxOptions fo = new FirefoxOptions();
fo.setBinary("C:\Users\ChawlaSh\AppData\Local\Mozilla Firefox\firefox.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("default");
fo.setProfile(myprofile);
driver = new FirefoxDriver(fo);
我希望这一定会有所帮助。
这个错误信息...
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
...表示您的程序无法创建新的 Firefox 浏览器 会话..
分析
有如下几个问题:
file.separator
:分隔文件路径组成部分的字符。在 UNIX 上是 /
,在 Windows 上是 \
。你也需要逃离他们。
- 您的 JDK 版本 是 1.8.0_151 非常 古老.
解决方案
- 使用
file.separator
作为\
与另一个\
.[=57=转义]
- 将JDK升级到最近的水平JDK 8u191。
- 确保 GeckoDriver-Firefox 映射
您的有效代码块将是:
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\Try out files\geckodriver.exe");
driver = new FirefoxDriver();
String baseURL = "http://www.google.com";
driver.get(baseURL);
我的版本是selenium-java-3.14.0和geckodriver-v0.23.0-win64。 我正在使用以下代码。
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\\Try out files\\geckodriver.exe");
driver = new FirefoxDriver();
String baseURL = "http://www.google.com";
driver.get(baseURL);
当我 运行 它时,我收到以下错误消息。
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: '*******', ip: '*****`enter code here`', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
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.W3CHandshakeResponse.lambda$new[=12=](W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession[=12=](ProtocolHandshake.java:122)
at java.util.stream.ReferencePipeline.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
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:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
at basicweb.FirefoxDriverDemo.main(FirefoxDriverDemo.java:17)
使用 firefox 版本 56 或 61 和 gecko 驱动程序版本 0.21。并添加 firefox 选项使用配置文件。
FirefoxOptions fo = new FirefoxOptions();
fo.setBinary("C:\Users\ChawlaSh\AppData\Local\Mozilla Firefox\firefox.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("default");
fo.setProfile(myprofile);
driver = new FirefoxDriver(fo);
我希望这一定会有所帮助。
这个错误信息...
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
...表示您的程序无法创建新的 Firefox 浏览器 会话..
分析
有如下几个问题:
file.separator
:分隔文件路径组成部分的字符。在 UNIX 上是/
,在 Windows 上是\
。你也需要逃离他们。- 您的 JDK 版本 是 1.8.0_151 非常 古老.
解决方案
- 使用
file.separator
作为\
与另一个\
.[=57=转义] - 将JDK升级到最近的水平JDK 8u191。
- 确保 GeckoDriver-Firefox 映射
您的有效代码块将是:
WebDriver driver; System.setProperty("webdriver.gecko.driver", "D:\Try out files\geckodriver.exe"); driver = new FirefoxDriver(); String baseURL = "http://www.google.com"; driver.get(baseURL);