Java org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;含硒3.5.3铬76
我正在用IntelliJ编写Selenium Junit测试。如果我直接从测试中触发,测试运行正常。然而,如果我使用JunitCore从TestRunnerSuite触发测试,我会遇到以下奇怪的错误,即在研究google之后,我没有找到解决方案。关于DriverService$builder的类似问题,但不是我的错误类型Java org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;含硒3.5.3铬76,java,selenium,selenium-chromedriver,guava,junit-runner,Java,Selenium,Selenium Chromedriver,Guava,Junit Runner,我正在用IntelliJ编写Selenium Junit测试。如果我直接从测试中触发,测试运行正常。然而,如果我使用JunitCore从TestRunnerSuite触发测试,我会遇到以下奇怪的错误,即在研究google之后,我没有找到解决方案。关于DriverService$builder的类似问题,但不是我的错误类型 [main] ERROR sire.responseOrg.TestIncidents - java.lang.AbstractMethodError: org.openqa.
[main] ERROR sire.responseOrg.TestIncidents - java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:332)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at sire.responseOrg.WebDrivers.getInstance(WebDrivers.java:15)
at sire.responseOrg.util.util1.setupChromeDriver(util1.java:51)
at sire.responseOrg.Test1.setUp(Test1.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ......Omitted
at org.junit.runner.JUnitCore.run(JUnitCore.java:127)
at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:76)
at sire.responseOrg.TestSuiteRunner.main(TestSuiteRunner.java:24)
完整的pom.xml依赖关系
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
<description>My description</description>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>main</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
<scope>main</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
<scope>main</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.6</version>
<scope>main</scope>
</dependency>
<dependency>
<groupId>com.salesforce.seti</groupId>
<artifactId>selenium-dependencies</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<packaging>pom</packaging>
</project>
如果从Test1.java开始测试,测试会定期运行,但会出现警告
[main] INFO projectname.util.util1 - Set up chrome driver.
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003}) on port 28755
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1566609934.853][WARNING]: This version of ChromeDriver has not been tested with Chrome version 76.
Aug 23, 2019 6:25:34 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[main] INFO projectname.util.util1 - Navigating to https://mytest.com/
但是,在添加testSuiteRunner后,如下所示
@RunWith(Suite.class)
@Suite.SuiteClasses({ Test1.class })
public class TestSuiteRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(Test1.class);
// print erros, exit etc omitted
}
}
现在我得到了奇怪的错误,无法启动chromedriver。
我的网络驱动程序是singleton
public class WebDrivers {
private static WebDriver driver = null;
public static WebDriver getInstance(){
if (driver == null) {
driver = new ChromeDriver();
}
return driver;
}
}
这是我第一次从地面开始布置一切。我不确定这是pom依赖性问题、单例webdriver问题还是其他问题。有谁能对这件事有共同的看法并提供一些线索吗?非常感谢 此错误消息
java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;
…意味着您正在使用的特定于guava依赖项的二进制文件版本之间存在一些不兼容
- 您使用的是chrome=76.0
- 您正在使用以下各项:
已解决。祝贺你 现在,根据您看到错误时的问题更新:<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-chrome-driver</artifactId> <version>3.5.3</version> <scope>test</scope> </dependency>
java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;
有两个方面java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
- NoClassDefFoundError:当Java虚拟机无法在运行时找到编译时可用的特定类时,会发生Java中的NoClassDefFoundError。您可以在中找到详细的讨论
:跟踪http/auth意味着http客户机仍在使用,如图所示:http/auth
实现详细信息来自Selenium v2.45.0中的HttpClient
HttpCommandExecutor
- 随着Selenium v3.11的可用性,Selenium网格被切换为使用
,而不是使用OkHttp
Apache HttpClient
- 此外,随着Selenium v3.141.0的发布,
从Apache HttpClient
中删除,这大大降低了 减小了selenium服务器分发包的大小Selenium server standalone
- 甚至apache支持的httpclient也被删除了
- 您可以在中找到详细的讨论
- 从POM中删除范围。
测试
或主要
当您从地面设置所有内容时,您的测试不需要运行。最好将selenium java更新为3.141.59或selenium 4-alpha,ChromeDriver 76.0.3809.126,如果可能,还可以使用Junit5@RahulL嗨,谢谢你的回复。我将selenium java更新为3.141.59,但运气不好。你能发布完整的pom吗?似乎程序无法使用您提供的文件夹结构和程序进行编译。(您的类被放在主文件夹下,但依赖范围是test。还要检查正在解决的“guava”依赖关系。非常感谢您提供的详细说明。我将selenium软件包更新为3.141.59,并将范围更改为main。但是现在没有运气,获取身份验证凭据时出错。我更新了错误消息和完整的pom.xml文件I。)n说明。非常感谢您的帮助。@user2751691签出更新的答案,如果您需要进一步的帮助,请告诉我。java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials