我们如何使用 selenium Web 驱动程序处理 chrome 和 Internet Explorer 的 SSL 证书错误。当我使用 Firefox 时,它运行良好。您能否为我提供处理 SSL 证书错误的解决方案。下面是我试过的代码。
// For Chrome
@Test
public void CRconfiguration() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
System.setProperty("webdriver.chrome.driver", "D:\\Softwares\\Selenium softwares\\drivers\\chromedriver.exe");
_driver = new ChromeDriver(capabilities);
System.setProperty("webdriver.chrome.driver",
"D:/Softwares/Selenium softwares/drivers/chromedriver.exe");
//_driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
login();
_driver.close();
}
//For Internet Explorer
@Test
public void IEconfiguration() throws Exception {
System.setProperty("webdriver.ie.driver",
"D:/Softwares/Selenium softwares/drivers/IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setJavascriptEnabled(true);
//capabilities.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
_driver = new InternetExplorerDriver(capabilities);
_driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
login();
_driver.close();
}