java - SessionNotCreatedException:无法找到一组匹配的功能 | 硒 geckodriver 失败
问题描述
我试图用 selenium 运行测试脚本,但得到了这个异常:org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
1601395316102 geckodriver INFO Listening on 127.0.0.1:15504
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'arch', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.8.12-arch1-1', java.version: '14.0.2'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
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:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at Test.main(Test.java:14)
Process finished with exit code 1
代码
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;
public class Test {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "src/main/resources/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.TRACE);
WebDriver driver = new FirefoxDriver(options);
driver.get("http://google.com");
driver.quit();
}
}
我的环境是:
- 操作系统:Arch Linux 5.8.12-arch1-1
- 浏览器:火狐浏览器版本:81.0(64位)
- 浏览器驱动版本:Geckodriver:0.27.0
- 语言:Java openjdk-14.0.2
- 硒版本:3.141.59
项目链接:github
依赖
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
解决方案
推荐阅读
- python - 计算数组中的反转次数(python代码)
- google-sheets - Google 表格:在单独的表格中选择单元格时,快速参考提示会阻止我的选择
- python - 如何使用 FFMPEG 驱动程序使 opencv 工作
- sql - 如何连接到 postgres 数据库。如果用户/角色密码在创建时被加密
- discord - 有没有办法发送游戏邀请?
- node.js - Mocha Sinon 变更构造函数
- python - 更改数据框/列的日期格式
- c# - 如何使不同的应用程序通过代理进行请求
- c - fscanf 格式 %[变长]s
- kubernetes - 检查 kubernetes 版本时出错