我已将我的 Selenium 框架升级到最新版本。在执行代码期间,我收到以下异常
例外:
org.openqa.selenium.InvalidArgumentException:
Invalid capabilities in alwaysMatch: unhandledPromptBehavior is type boolean instead of string
细节 :
Selenium:3.7.1 IE:3.7.0(32 位驱动程序)java.version:'1.8.0_144'
自动化代码适用于我较旧的 IE 驱动程序(32 位)- 3.4.0。
请提出您的意见以解决该错误。
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();