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:
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?