0

I am getting this error while executing program in Eclipse. I am trying to open fb using selenium. Code trials:

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;
    at org.openqa.selenium.chrome.AddHasCasting.getAdditionalCommands(AddHasCasting.java:38)
    at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.getExtraCommands(ChromeDriver.java:99)
    at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.<init>(ChromeDriver.java:94)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:82)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:50)
    at Practice.OpenBrowser.main(OpenBrowser.java:15)

Please help.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

This error message...

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;

...implies that the file com/google/common/collect/ImmutableMap might be corrupted or there is some incompatibility between the version of the binaries you are using specifically with the guava version / dependency (maven).


You need to take care of a couple of things as follows:

  • In the System.setProperty() line you have passed the absolute location of the ChromeDriver/GeckoDriver as follows:

    System.setProperty("webdriver.chrome.driver","C:\\path\\to\\chromedriver.exe");
    
  • Incase you are using deleting the corrup/incompatible .m2 folder can solve your issue.

  • Upgrade JDK to recent levels JDK 8u351.

  • Upgrade Selenium to current levels Version 3.141.59.

  • ChromeDriver is updated to current ChromeDriver v109.0 level.

  • Chrome Browser is updated to current chrome=109.0 (as per chromedriver=102.0.5005.61 release notes).


Reference

You can find a relevant discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352