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 :
Selenium: 3.7.1 IE : 3.7.0 (32 Bit Driver) java.version: '1.8.0_144'
Automation code works with my older IE Driver (32 Bit) - 3.4.0.
Please suggest your view to resolve the error .
capabilities.setCapability("UNHANDLED_PROMPT_BEHAVIOUR" ,false);
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());
opt = new InternetExplorerOptions();
opt.merge(capabilities);
driver = new InternetExplorerDriver(opt);
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
In short:
"unhandledPromptBehavior"
"unhandledPromptBehavior"
AND for"unexpectedAlertBehavior"
are:"accept"
,"dismiss"
,"accept and notify"
,"dismiss and notify"
,"ignore"
. But W3C supports only 1st and 2nd.In details:
UNHANDLED_PROMPT_BEHAVIOUR is a constant name from
CapabilityType
interface. But you use it as string. So eithercapabilities.setCapability("unhandledPromptBehavior", ...)
orcapabilities.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, ...)
Values for those capabilities are encauntered in enum
org.openqa.selenium.UnexpectedAlertBehaviour
: it is becauseunhandledPromptBehavior
is new updated name forunexpectedAlertBehaviour
in webdriver3. Actually when you set unexpectedAlertBehaviour the webdriver (v3.8) automatically set both values.So root cause of your error is the line:
capabilities.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, true)
:You should replace
true
to valid value (see above). This line actually set both capabilities:unhandledPromptBehavior
andunexpectedAlertBehaviour
. Your first line (with "UNHANDLED_PROMPT_BEHAVIOR") just ignored by driver.