I am trying to upgrade to Selenium 4. This error occurs: java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.setExperimentalOption(Ljava/lang/String;Ljava/lang/Object;)
Here is the code used to set the options:
WebDriver driver = new ChromeDriver(getChromeOptions());
private ChromeOptions getChromeOptions() {
try {
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", fileLocation);
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("start-maximized");
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
return options;
} catch (Exception e) {
LOG.error("Exception building options", e);
}
return null;
}
Using chromedriver version 95.0.4638.54
I thought it upgrading would be as simple as changing the version number in the pom. I found this while researching:
In Selenium 4, DesiredCapabilities have been replaced by Options. To use the Driver class, QAs have to create an Options class, set test requirements, and pass the object to the Driver constructor.
I may implemented the above incorrectly. I am at a loss at this point. Any kind help would be greatly appreciated.