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");
}
}热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下