NoSuchMethodError:'java.io.OutputStream org.openqa.selenium.chrome.ChromeDriverService$Builder.getLogOutput(java.lang.String)'

问题描述 投票:0回答:1

java.lang.NoSuchMethodError:'java.io.OutputStream org.openqa.selenium.chrome.ChromeDriverService$Builder.getLogOutput(java.lang.String)'

at org.openqa.selenium.chrome.ChromeDriverService$Builder.createDriverService(ChromeDriverService.java:356)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.createDriverService(ChromeDriverService.java:160)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:494)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:156)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
at com.nghl.selenium.framework.BaseTest.browserSetUp(BaseTest.java:202)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:823)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:590)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)

enter image description here

依赖关系显示这样的行:

enter image description here

尝试将依赖项更改为最新版本,甚至尝试在 IntelliJ 中进行清理和清除缓存,并且在线提供了许多此类解决方法。

selenium-webdriver testng webdriver-manager webdrivermanager-java
1个回答
0
投票

发生这种情况是因为

io.appium
下载
selenium-remote-driver:jaar:4.12.1

[INFO] +- io.appium:java-client:jar:8.5.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-api:jar:4.12.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-remote-driver:jar:4.12.1:compile

但是 4.10.0 版本在 selenium 库中使用:

[INFO] \- org.seleniumhq.selenium:selenium-chrome-driver:jar:4.10.0:compile
[INFO]    +- com.google.auto.service:auto-service-annotations:jar:1.0.1:compile
[INFO]    +- com.google.auto.service:auto-service:jar:1.0.1:compile
[INFO]    |  \- com.google.auto:auto-common:jar:1.2:compile
[INFO]    +- com.google.guava:guava:jar:31.1-jre:compile
[INFO]    |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO]    |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO]    |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO]    |  +- org.checkerframework:checker-qual:jar:3.12.0:compile
[INFO]    |  +- com.google.errorprone:error_prone_annotations:jar:2.11.0:compile
[INFO]    |  \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO]    +- org.seleniumhq.selenium:selenium-api:jar:4.10.0:compile
[INFO]    +- org.seleniumhq.selenium:selenium-chromium-driver:jar:4.10.0:compile
[INFO]    +- org.seleniumhq.selenium:selenium-json:jar:4.10.0:compile
[INFO]    +- org.seleniumhq.selenium:selenium-manager:jar:4.10.0:compile
[INFO]    \- org.seleniumhq.selenium:selenium-remote-driver:jar:4.10.0:compile

特别是在 ChromeDriverService 中:

service.sendOutputTo(getLogOutput(CHROME_DRIVER_LOG_PROPERTY));

selenium-remote-driver:jaar:4.12.1
中没有带有一个参数的 getLogOutput 方法,但在
selenium-remote-driver:jar:4.10.0
中它存在

要解决此问题,您可以从

selenium-remote-driver
 中排除 
io.appium

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.appium</groupId>
                <artifactId>java-client</artifactId>
                <version>8.5.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-remote-driver</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    </dependencyManagement>
© www.soinside.com 2019 - 2024. All rights reserved.