WebDriver
会打开浏览器窗口,但我会收到SEC_ERROR_UNKNOWN_ISSUER
。
我尝试在浏览器中添加此站点作为例外,但是当新的浏览器窗口打开时,我再次收到相同的消息,而不是网站。
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
options.setLogLevel(Level.ALL);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);
WebDriver driver = new FirefoxDriver(capabilities);
答案 0 :(得分:1)
您需要将setAcceptInsecureCerts
功能设置为true
这个简单的代码对我有用: -
System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setAcceptInsecureCerts(true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get("https://self-signed.badssl.com/");
OR
System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("acceptInsecureCerts", true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get("https://self-signed.badssl.com/")
在第一行代码中更改您的gecko路径。更新gecko驱动和firefox