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");
}
}热门推荐
2 祝福语简短教师节
10 双节贺词祝福语简短
11 羊年祝福语简短文案
12 小女孩简短祝福语
13 祝福语上班文案简短精辟
14 元旦快乐祝福语简短版
15 大学师兄毕业祝福语简短
16 异地生日祝福语老公简短
17 冬至的祝福语唯美简短
18 便利贴祝福语简短幼儿