org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;与硒 3.5.3 铬 76 [英] org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList; with Selenium 3.5.3 Chrome 76

查看:30
本文介绍了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 上的类似问题,但不是我的错误类型.

[main] 错误sire.responseOrg.TestIncidents - java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;在 org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:332)在 org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)在 org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)在sire.responseOrg.WebDrivers.getInstance(WebDrivers.java:15)在sire.responseOrg.util.util1.setupChromeDriver(util1.java:51)在sire.responseOrg.Test1.setUp(Test1.java:28)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在……省略在 org.junit.runner.JUnitCore.run(JUnitCore.java:127)在 org.junit.runner.JUnitCore.runClasses(JUnitCore.java:76)在sire.responseOrg.TestSuiteRunner.main(TestSuiteRunner.java:24)

我正在使用 Selenium 3.5.3 和 chrome 76.--->已更新到 Selenium 3.141.59,并且具有 main 范围.
现在出现错误

java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials在 org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:93)在 org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:72)在 org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:63)在 org.openqa.selenium.chrome.ChromeDriverCommandExecutor.<init>(ChromeDriverCommandExecutor.java:36)在 org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)在 org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)在 org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)在sire.responseOrg.WebDrivers.getInstance(WebDrivers.java:15)在sire.responseOrg.util.SeleniumUtil.setupChromeDriver(SeleniumUtil.java:62)在sire.responseOrg.TestIncidents.setUp(TestIncidents.java:29)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:498)在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)在 org.junit.runners.ParentRunner.run(ParentRunner.java:292)在 org.junit.runners.Suite.runChild(Suite.java:128)在 org.junit.runners.Suite.runChild(Suite.java:24)在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)在 org.junit.runners.ParentRunner.run(ParentRunner.java:292)在 org.junit.runner.JUnitCore.run(JUnitCore.java:157)在 org.junit.runner.JUnitCore.run(JUnitCore.java:136)在 org.junit.runner.JUnitCore.run(JUnitCore.java:127)在 org.junit.runner.JUnitCore.runClasses(JUnitCore.java:76)在sire.responseOrg.TestSuiteRunner.main(TestSuiteRunner.java:24)引起:java.lang.ClassNotFoundException:org.apache.http.auth.Credentials在 java.net.URLClassLoader.findClass(URLClassLoader.java:381)在 java.lang.ClassLoader.loadClass(ClassLoader.java:424)在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)在 java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 33 更多

完整的 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><版本>1.0-SNAPSHOT</版本><description>我的描述</description><依赖关系><!-- https://mvnrepository.com/artifact/junit/junit --><依赖性><groupId>junit</groupId><artifactId>junit</artifactId><版本>4.9</版本><范围>主要</范围></依赖><依赖性><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-api</artifactId><版本>3.141.59</版本></依赖><依赖性><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-java</artifactId><版本>3.141.59</版本></依赖><依赖性><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-chrome-driver</artifactId><版本>3.141.59</版本><范围>主要</范围></依赖><!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --><依赖性><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><版本>1.7.6</版本><范围>主要</范围></依赖><!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple --><依赖性><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId><版本>1.7.6</版本><范围>主要</范围></依赖><依赖性><groupId>com.salesforce.seti</groupId><artifactId>硒依赖项</artifactId><版本>1.0.3</版本></依赖></依赖关系><构建><插件管理><插件><插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><版本>3.5.1</版本><配置><来源>1.8</来源><目标>1.8</目标></配置></插件><插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><版本>3.1.2</版本><执行><执行><目标><目标>测试罐</目标></目标></执行></执行></插件></插件></插件管理></构建><包装>pom</包装></项目>

我的项目文件夹结构是

.src...主要的.....java.......项目名.........常量文件夹.........实用文件夹......util1.java......util2.java.........Test1.java.........TestRunnerSuite.java.........WebDrivers.java

如果我从 Test1.java 开始测试,测试会定期运行,但会出现警告

[main] INFO projectname.util.util1 - 设置 chrome 驱动程序.在端口 28755 上启动 ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003})只允许本地连接.请保护 ChromeDriver 和相关测试框架使用的端口,防止恶意代码访问.[1566609934.853][警告]:此版本的 ChromeDriver 尚未使用 Chrome 版本 76 进行测试.2019 年 8 月 23 日下午 6:25:34 org.openqa.selenium.remote.ProtocolHandshake createSession信息:检测到的方言:W3C[main] INFO projectname.util.util1 - 导航到 https://mytest.com/

但是,在添加 testSuiteRunner 之后,如下所示.

@RunWith(Suite.class)@Suite.SuiteClasses({ Test1.class })公共类 TestSuiteRunner {公共静态无效主要(字符串[]参数){结果 result = JUnitCore.runClasses(Test1.class);//打印错误,退出等省略}}

现在我收到奇怪的错误,无法启动 chromedriver.我的 webdriver 是单例的

公共类 WebDrivers {私有静态 WebDriver 驱动程序 = null;公共静态 WebDriver getInstance(){如果(司机==空){驱动程序 = 新的 ChromeDriver();}回程司机;}}

这是我第一次在场地上进行设置.我不确定是 pom 依赖问题、单例 webdriver 问题还是其他问题.任何人都可以分享对此的看法并提供一些线索吗?非常感激.

解决方案

这个错误信息...

java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;

...暗示您使用的二进制文件版本之间存在一些不兼容,特别是 guava 依赖.p>

  • 您正在使用 chrome= 76.0
  • 您正在使用以下内容:

    <依赖><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-chrome-driver</artifactId><版本>3.5.3</版本><范围>测试</范围></依赖>

  • 您的 Selenium 客户端 版本是 3.5.3,比它早 2 年.

  • 我们不知道您的 JDK 版本.

所以 Selenium Client v3.5.3Chrome 浏览器 v76.0

之间存在明显的不匹配

但是根据以下讨论:

这些问题是由于不兼容的 Guava 依赖关系而出现的.

<块引用>

selenium-java-3.141.59 中使用的当前 guava 版本是 guava-25.0-jre

<小时>

解决方案

确保:

  • JDK 升级到当前级别 JDK8u222.
  • Selenium 已升级到当前级别版本 3.141.59.
  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖.
  • 如果您的基本 Web 客户端 版本太旧,请卸载它并安装最新的 GA 和发布版本的 Web 客户端.
  • 进行一次系统重启.
  • 非 root 用户身份执行您的 @Test.
  • 总是在 tearDown(){} 方法中调用 driver.quit() 来关闭 &优雅地销毁 WebDriverWeb Client 实例.
<小时>

更新

所以大概你关于错误的主要问题:

java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;

解决.恭喜.

现在,根据您看到错误的问题更新:

java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

有两个方面.

I'm writing Selenium Junit tests with IntelliJ. The tests run ok if I trigger from test directly. However, if I trigger tests from TestRunnerSuite with JunitCore, I encountered following weird error that I did not find a solution after researching on google. Similar questions on DriverService$builder, but not my error type.

[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)

I'm using Selenium 3.5.3 and chrome 76.---> Updated to Selenium 3.141.59,and with main scope.
Now getting error

java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
    at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:93)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:72)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:63)
    at org.openqa.selenium.chrome.ChromeDriverCommandExecutor.<init>(ChromeDriverCommandExecutor.java:36)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at sire.responseOrg.WebDrivers.getInstance(WebDrivers.java:15)
    at sire.responseOrg.util.SeleniumUtil.setupChromeDriver(SeleniumUtil.java:62)
    at sire.responseOrg.TestIncidents.setUp(TestIncidents.java:29)
    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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
    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)
Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 33 more

Full pom.xml dependencies

<?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>

My project folder structure is

.src
...main
.....java
.......projectname
.........constantsFolder
.........utilFolder
...........util1.java
...........util2.java
.........Test1.java
.........TestRunnerSuite.java
.........WebDrivers.java

If I start test from Test1.java, the test runs regularly though with warnings

[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/

However, after adding a testSuiteRunner as below.

@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
    }
}

Now I get the weird error and cannot fire the chromedriver. The webdriver I have is singleton

public class WebDrivers {
    private static WebDriver driver = null;

    public static WebDriver getInstance(){
        if (driver == null) {
            driver = new ChromeDriver();
        }
        return driver;
    }
}

It's my first time to work on setting everything up from grounds. I'm not sure if it's pom dependency issue, singleton webdriver issue, or something else. Could anyone share an eyesight on this and give some clues? Much appreciated.

解决方案

This error message...

java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;

...implies that there is some incompatibility between the version of the binaries you are using specifically with the guava dependency.

  • You are using chrome= 76.0
  • You are using the following:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.5.3</version>
        <scope>test</scope>
    </dependency>
    

  • Your Selenium Client version is 3.5.3 which is more then 2 years older.

  • Your JDK version is unknown to us.

So there is a clear mismatch between the Selenium Client v3.5.3 and Chrome Browser v76.0

However as per the discussions in:

These issues crop up due to incompatibile Guava dependency.

The current guava version used within selenium-java-3.141.59 is guava-25.0-jre


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u222.
  • Selenium is upgraded to current levels Version 3.141.59.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Update

So presumably your main question with respect to the error:

java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;

is solved. Congratulations.

Now, as per your question update as you are seeing the error:

java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

There are two aspects.

这篇关于org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;与硒 3.5.3 铬 76的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆