2

I'm launching Selenium WebDriver v3.141.59 via DesiredCapabilities using the following code:

FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addPreference("dom.popup_maximum", 100);
firefoxOptions.addPreference("dom.webnotifications.enabled", false);
firefoxOptions.addPreference("media.peerconnection.enabled", false);

DesiredCapabilities dc = DesiredCapabilities.firefox();

Proxy proxy = new Proxy();
...


dc.setCapability(CapabilityType.PROXY, proxy);

firefoxOptions.merge(dc); <- throws: java.lang.NoSuchMethodError

Which throws the following exception:

java.lang.NoSuchMethodError: org.openqa.selenium.firefox.FirefoxOptions.merge(Lorg/openqa/selenium/Capabilities;)Lorg/openqa/selenium/firefox/FirefoxOptions

I looked into this extensively and found that the method merge() is defined in MutableCapabilities which was added starting from Selenium v3.7.0.

I checked my POM file and confirmed that I am indeed running the latest version of Selenium:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version> <-
</dependency>

I thought the error might be due to a transitive dependency so I checked the POM file of every project in my Eclipse Workspace and confirmed that they're all using Selenium v3.141.59.

However, I did notice that:

<dependency> for selenium-java implicitly also includes the <dependency> for guava.

I'm pretty sure the error is the result of an incompatible Guava version as pointed out in a comment by @GhostCat on this thread.

But how do I confirm this? When I look at the Dependency Hierarchy in Eclipse it clearly shows Guava Java 25.0-jre as the compiled version (which is compatible with the version of Selenium I'm running). Please see the screenshot below:

enter image description here

Is it possible for an incompatible version of Guava to bubble up as an exception in Selenium method merge()? If so, how would I confirm whether such a conflict exists? And more importantly, how would I pinpoint which library or dependency is responsible for this conflict? I've spent several days trying to debug this issue but the root cause still remains elusive.

How can I troubleshoot it?

Bradford Griggs
  • 439
  • 2
  • 15
  • Did you try to clean and rebuild `Maven` project to see if the problem persists? – Vance Brockberg Sep 01 '21 at 17:44
  • @VanceBrockberg yes – Bradford Griggs Sep 01 '21 at 18:00
  • I do not think this is related to guava. The method mentioned is from Selenium libs. What if you run your tests from command line using maven? Does the error persist? – Alexey R. Sep 02 '21 at 06:08
  • The issue seems to be that you don't have a problem in compilation time, otherwise you would have compilation error, but have an issue in run time. In run time your code has older version of libs in its classpath. – Alexey R. Sep 02 '21 at 06:13
  • @AlexeyR. yes, you are correct - no issue at compile time. The question is, how would I find which project/library is causing the problem? Is there some kind of systematic approach that can be taken? Thanks – Bradford Griggs Sep 02 '21 at 16:40
  • So are you able to run that code successfully using maven? We need to check if the issues related to your IDE or to something different. How do you actually run your code? – Alexey R. Sep 02 '21 at 16:43
  • @AlexeyR. The code compiles but at runtime it throws an exception and doesn't run. – Bradford Griggs Sep 02 '21 at 16:45

0 Answers0