I'm getting: NoSuchMethodError: org.openqa.selenium.firefox.FirefoxOptions.merge
when I try launching Selenium WebDriver
:
My code in main
calls a single method:
WebDriver driver = new WebDriverProfile().getTMPFirefoxProfile(null); // Parameter is optional
I am posting my code in detail in the hope that perhaps someone will be able to offer a suggestion to guide me in the right direction.
Stack trace:
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.firefox.FirefoxOptions.merge(Lorg/openqa/selenium/Capabilities;)Lorg/openqa/selenium/firefox/FirefoxOptions;
at webdriverX.WebDriverProfile.getTMPFirefoxProfile(WebDriverProfile.java:286)
at n.NMain.main(NMain.java:22)
The call to getTMPFirefoxProfile(ProxyPOJO proxyPOJO)
calls the code:
public WebDriver getTMPFirefoxProfile(ProxyPOJO proxyPOJO) throws InterruptedException, MalformedObjectNameException, InstanceNotFoundException, ReflectionException {
System.setProperty("webdriver.gecko.driver", GlobalVar.geckdriverExecutableFilePath); // Verified path is correct via syso
DesiredCapabilities capabilities = new DesiredCapabilities();
if (proxyPOJO != null) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyPOJO.getProxyIP() + ":" + proxyPOJO.getProxyPort());
proxy.setFtpProxy(proxyPOJO.getProxyIP() + ":" + proxyPOJO.getProxyPort());
proxy.setSslProxy(proxyPOJO.getProxyIP() + ":" + proxyPOJO.getProxyPort());
capabilities.setCapability(CapabilityType.PROXY, proxy);
}
DesiredCapabilities dc = DesiredCapabilities.firefox();
FirefoxOptions opt = new FirefoxOptions();
opt.merge(dc);
opt.addPreference("dom.popup_maximum", 200);
opt.addPreference("dom.webnotifications.enabled", false);
opt.merge(capabilities);
WebDriver driver = WebDriverX.getNewFireFoxWebDriver(opt);
return driver;
}
The call to: getNewFireFoxWebDriver(FirefoxOptions firefoxOptions)
calls this code:
if (firefoxOptions != null) {
driver = new FirefoxDriver(firefoxOptions);
} else {
driver = new FirefoxDriver();
}
return driver;
I've asked a similar question however I've now tried almost 10 different suggestions - none of which solved my problem.
Below I will outline the steps I took to try to solve the problem:
1) Right clicked project -> Maven clean -> Maven build -> Maven test (I tried each one separately and then all one after the next)
2) Clicked Project -> clean
3) Confirmed Firefox is updated to latest version (version 72)
4) Removed the library guava
(the only suggested conflict) from project POM
5) Shutdown and restarted Eclipse
6) Deleted all run configurations and ran project from scratch
7) Re-downloaded GeckoDriver v0.26.0 to make sure I have the lestest version installed
8) I Made sure my POM file contains Selenium
dependency version 3.141.591
which contains merge
method
I'm out of options.. What do I try next?
Below is the contents of the project POM
file:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<classifier>models</classifier>
</dependency>
<dependency>
<groupId>uk.ac.abdn</groupId>
<artifactId>SimpleNLG</artifactId>
<version>4.4.8</version>
</dependency>
</dependencies>
I have two other projects linked in the build path of this project. From one project, I am able to call getTMPFirefoxProfile(ProxyPOJO proxyPOJO)
without any issues. From the other one, I get the same error I get with current project. What does this mean? I analyzed the other project and I don't see any conflicting dependencies.
I spent the entire day trying to troubleshoot the issue but I feel completely lost..
Any ideas?
Thanks!