I have upgraded my Selenium framework to the latest version. During execution of the code, I receive the following exception:
Exception:
org.openqa.selenium.InvalidArgumentException:
Invalid capabilities in alwaysMatch: unhandledPromptBehavior is type boolean instead of string
Details:
Also newer version suggests driver = new InternetExplorerDriver(capabilities);
is deprecated. I am setting capabilities of the browser separately in a function and passing it as a parameter in Driver.
How to resolve this issue?
Code snippet:
desiredCapabilities(browser);
IE Capabilities Setting:-
capabilities = new DesiredCapabilities().internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
capabilities.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, true);
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
capabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
capabilities.setCapability("nativeEvents", false);
capabilities.setCapability("requireWindowFocus", false);
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("ignoreProtectedModeSettings", true);
System.setProperty("webdriver.ie.driver", ieExe.getAbsolutePath());
Then I invoke my driver:
driver = new InternetExplorerDriver(capabilities);
Well, the Selenium
implementation from v3.7
on wards no more accepts DesiredCapabilities
type objects as a parameter to initialize Web Browser
instances rather only strongly typed Options
classes are preferred. So you have to use InternetExplorerOptions
Class object, use merge
argument from MutableCapabilities
and pass as a parameter. Your code block will be as follows :
System.setProperty("webdriver.ie.driver", "C:\\Utility\\BrowserDrivers\\IEDriverServer.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS", true);
capabilities.setCapability("ACCEPT_SSL_CERTS", true);
capabilities.setCapability("SUPPORTS_ALERTS", true);
capabilities.setCapability("UNEXPECTED_ALERT_BEHAVIOR", true);
capabilities.setCapability("IE_ENSURE_CLEAN_SESSION", true);
capabilities.setCapability("ENABLE_ELEMENT_CACHE_CLEANUP", true);
capabilities.setCapability("nativeEvents", false);
capabilities.setCapability("requireWindowFocus", false);
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("ignoreProtectedModeSettings", true);
InternetExplorerOptions opt = new InternetExplorerOptions();
opt.merge(capabilities);
WebDriver driver = new InternetExplorerDriver(opt);