Selenium Webdriver 如何处理 Edge 中的 SSL 证书?
我们可以使用Seleniumwebdriver在Edge浏览器中处理SSL证书。这是在EdgeOptions类的帮助下完成的。我们将创建此类的一个对象并将参数setAcceptInsecureCerts设置为true值。
最后,必须将此信息传递给webdriver对象以获得所需的浏览器设置。SSL是一种旨在在服务器和浏览器之间建立安全连接的协议。
语法
EdgeOptions e = new EdgeOptions(); e.setAcceptInsecureCerts(true);
代码实现
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class EdgeBrwserSSL{
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver",
"C:\\Users\\ghs6kor\\Desktop\\Java\\msedgedriver.exe");
//EdgeOptions的实例
EdgeOptions e = new EdgeOptions();
//将setAcceptInsecureCerts配置为true布尔值
e.setAcceptInsecureCerts(true);
//EdgeDriver的对象
WebDriver driver = new EdgeDriver(e);
//隐式等待
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//网址启动
driver.get("application url");
}
}热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志