如何解决正确的番石榴硒?

How resolve right guava for selenium?

我知道类似的问题很少,但它们大多已经过时,无助于解决我的问题。

使用 Selenium:4.0.0-alpha-3(尝试使用 3.141.59 有同样的问题)和 apache surefire:3.0.0-M3

番石榴依赖树:

[INFO] +- org.seleniumhq.selenium:selenium-java:jar:4.0.0-alpha-3:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-edge-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-edgehtml-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-xpi-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-opera-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-remote-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  +- org.seleniumhq.selenium:selenium-safari-driver:jar:4.0.0-alpha-3:compile
[INFO] |  |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] |  \- org.seleniumhq.selenium:selenium-support:jar:4.0.0-alpha-3:compile
[INFO] |     \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO] \- org.seleniumhq.selenium:selenium-chrome-driver:jar:4.0.0-alpha-3:compile
[INFO]    +- com.google.guava:guava:jar:27.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]    +- org.seleniumhq.selenium:selenium-chromium-driver:jar:4.0.0-alpha-3:compile
[INFO]    |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO]    +- org.seleniumhq.selenium:selenium-devtools:jar:4.0.0-alpha-3:compile
[INFO]    |  \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)
[INFO]    \- org.seleniumhq.selenium:selenium-http:jar:4.0.0-alpha-3:compile
[INFO]       \- (com.google.guava:guava:jar:27.1-jre:compile - omitted for duplicate)

创建新的 ChromeDriver 时出现以下异常,但如果我从 pox.xml 中删除 surefire 依赖项,一切都会运行。

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;

    at org.openqa.selenium.os.ExecutableFinder.<clinit>(ExecutableFinder.java:33)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:133)
    at org.openqa.selenium.chrome.ChromeDriverService.access[=11=]0(ChromeDriverService.java:35)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:177)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:363)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:100)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:105)
    at com.swx.ptp.ctest.gui.CnsSample.webCnsOpen(CnsSample.java:15)
    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.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod[=11=](ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke[=11=](ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod(TestMethodTestDescriptor.java:202)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:135)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute(DefaultLauncher.java:197)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

我试过插入最新的 guava 依赖项,但没有成功。

System.out.println(com.google.common.collect.ImmutableSet.class.getResource("ImmutableSet.class"));
jar:file:/C:/.../.m2/repository/com/google/code/google-collections/google-collect/snapshot-20080530/google-collect-snapshot-20080530.jar!/com/google/common/collect/ImmutableSet.class

将 maven surefire 从 v3.0.0-M3 降级到 v2.22.2 解决了问题