15

I keep getting the above error (full text below) with guava-23.6-jre.jar I'm doing everything with IntelliJ IDEA so I don't have pom.xml anywhere in my project. My code does nothing special, the line 39 is the setProperty() call:

    @Before
    public void Setup(){
        System.setProperty("webdriver.chrome.driver", "/Users/xxxxx/Documents/Java/end2endtests/chromedriver");
        _driver = new ChromeDriver();
        _helper = new WebDriverHelper(_driver);
        _wait = new WebDriverWait(_driver, Constants.SPIN_WAIT_TIMEOUT);
}

The error is

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;

at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:306)
at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:107)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
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 PlaylistTest.Setup(PlaylistTest.java:39)
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:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
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)

and here is the list of the packages I have installed:

animal-sniffer-annotations-1.14.jar jackson-databind-2.8.9.jar
bcpkix-jdk15on-1.58.jar         jcl-over-slf4j-1.7.25.jar
bcprov-jdk15on-1.58.jar         jsr305-1.3.9.jar
browsermob-core-2.1.5.jar       junit-4.12.jar
byte-buddy-1.7.9.jar            jzlib-1.1.3.jar
checker-compat-qual-2.0.0.jar       littleproxy-1.1.0-beta-bmp-17.jar
commons-codec-1.10.jar          mitm-2.1.5.jar
commons-exec-1.3.jar            netty-all-4.0.51.Final.jar
commons-lang3-3.5.jar           okhttp-3.9.1.jar
commons-logging-1.2.jar         okio-1.13.0.jar
dnsjava-2.1.8.jar           selenium-api-3.9.1.jar
error_prone_annotations-2.0.18.jar  selenium-chrome-driver-3.9.1.jar
error_prone_annotations-2.1.3.jar   selenium-edge-driver-3.9.1.jar
gson-2.8.2.jar              selenium-firefox-driver-3.9.1.jar
guava-23.0-android.jar          selenium-ie-driver-3.9.1.jar
guava-23.6-jre.jar          selenium-java-3.9.1.jar
hamcrest-core-1.3.jar           selenium-opera-driver-3.9.1.jar
httpclient-4.5.3.jar            selenium-remote-driver-3.9.1.jar
httpcore-4.4.6.jar          selenium-safari-driver-3.9.1.jar
j2objc-annotations-1.1.jar      selenium-server-standalone-3.9.1.jar
jackson-annotations-2.8.9.jar       selenium-support-3.9.1.jar
jackson-core-2.8.9.jar          slf4j-api-1.7.25.jar
Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39
  • Could you post more code here? What do you have in this line `PlaylistTest.Setup(PlaylistTest.java:39)`. Also list of libs you use would be helpful, too, cause it seems like libraries versions conflict. – Sergei Sirik Feb 21 '18 at 19:38
  • Thanks @SergeiSirik, I have added the lib directory listing and my code. – Nick Slavsky Feb 21 '18 at 20:18
  • 1
    Try eliminating one of the two guava dependencies. You should only specify one. – MikeJRamsey56 Feb 21 '18 at 20:35
  • @MikeJRamsey56 no, they're different. The Android one comes from browsermob which i need. However the issue was most probably caused by `selenium-server-standalone-3.9.1.jar` – Nick Slavsky Feb 21 '18 at 20:44
  • Try removing guava-23.6-jre.jar. See [Guava: Google Core Libraries for Java](https://github.com/google/guava). – MikeJRamsey56 Feb 21 '18 at 20:47
  • well, the JRE one is needed for selenium-java and it uses the 23.6 version. Anyway, @MikeJRamsey56, like I said, I managed to get it to work, and both guava libraries are there. So the problem was caused by something else, **most likely** by the standalone driver. – Nick Slavsky Feb 21 '18 at 20:51
  • 2
    Suit yourself. But you should avoid conflicts between multiple versions of Guava. – MikeJRamsey56 Feb 21 '18 at 21:04

10 Answers10

2

I faced the same issue while using TestNG 7.4.0, and solved it by specifying:

implementation 'com.google.guava:guava:30.1.1-jre' 
johnnyaug
  • 887
  • 8
  • 24
HongQuanTo
  • 21
  • 2
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 04 '21 at 11:28
1

Do not run your RemoteWebDriver selenium tests from AndroidStudio unless you know how to remove guava conflicts in the IDE. After cleaning up guava dependencies in my gradle file as in:

testImplementation "com.google.guava:guava:28.2-jre" testImplementation ('org.seleniumhq.selenium:selenium-chrome-driver:4.0.0-alpha-4'){ exclude group: "com.google.guava", module:"guava" }

I executed my tests from IntelliJ community edition and they worked!!. It seems that Android Studio forces its own version of guava

Oscar Montoya
  • 177
  • 1
  • 8
1

I faced the same issue as my testng version updated to 7.3 from 7.1, while selenium was on 3.141.59.

Reverting testng version or updating selenium should resolve the issue

1

I faced the same issue as my testng version updated to 7.3 from 7.0.0, while selenium was on 3.141.59. "Project was Maven" and Issue resolved ( chrome browser was launched )

0

I got the same issue using whatever default version of selenium lib I had installed. Explicitly defining the dependency solved it:

adding explicit selenium dependency

Almund
  • 5,695
  • 3
  • 31
  • 35
  • Unfortunately this didn't work for me. I have both chromedriver and remote webdriver explicitly defined and I'm still getting the issue – Joelle Boulet Apr 05 '22 at 17:53
  • It was a long time since I did this but, have you confirmed what version of the Java and what versions (not only explicitly setting them but the right versions) of ChromeDriver and WebDriver you are using? – Almund Apr 07 '22 at 05:20
  • Selenium is 4.1.3, chromedriver.exe is 100.0.4896.20. I started another project in my IDE and redid my config (in my case maven) with the same dependencies (and versions) and got it to work with just selenium and testng being specified (without specifying the chrome-driver maven dependency version). As far as I can tell something wasn't being cleaned up from an older build of the project leaving multiple guava versions around. Even doing a clean in the old broken project I still get the error but the new project that started with the same config is happy to run without issue. – Joelle Boulet Apr 13 '22 at 21:24
  • @JoelleBoulet curious. It seems you are closing in on the issue though. Unfortunately, I'm no longer working in Java so I can't reproduce or anything here, even give much tips on how to troubleshoot. Perhaps the best you can do is to wipe the selenium setup completely and start clean as you got it to work in your other project? – Almund Apr 14 '22 at 04:40
0

I fixed my issue by removing external JARS:

enter image description here

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
ADISU
  • 9
  • 1
0

Just Add a dependency in your Pom.xml file, issue will resolve

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>24.0-jre</version>
</dependency>
0

I got the same exception for Selenium dependency and I have solved this by changing the dependency from testCompile to compile in build.gradle file.

testCompile compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
     ------->>>
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
Dharman
  • 30,962
  • 25
  • 85
  • 135
PrakashFrancis
  • 171
  • 2
  • 12
0

In case some has a mess of a project like my self...

If you are mixing a lot of libraries com.google.guava:guava can be override by another dependency, the solution is check the dependency tree from the application, then delete/modify/override the dependencies to avoid conflicts between libs

osdamv
  • 3,493
  • 2
  • 21
  • 33
0

The issue is due to the libraries, I took guava 32 version with selenium 4.9.1. It worked for me. I was able to launch the chrome browser successfully.

  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/34500563) – dpapadopoulos Jun 07 '23 at 15:13