Selenium Webdriver如何处理Firefox中的SSL证书?
我们可以通过使用FirefoxProfile类,利用Selenium webdriver来处理Firefox中的SSL证书。 然后将parametersetAcceptUntrustedCertificates参数设置为true。 SSL是一种用来在客户端(浏览器)和服务器之间创建安全连接的协议。
SSL会检查网站的真实性,并在访问者向该网站发送或获取信息时对访问者进行编码。SSL证书的一些优点有:-
通过增加业务增长来赢得用户的信任。
为在线支付提供一个安全网关,用于保护用户名、密码以及其他银行信息等客户数据。
远离黑客威胁。
树立良好的品牌价值,例如谷歌会给拥有有效SSL的网站一个好的排名。
SSL证书网站以https://开头,在那里我们可以在地址栏中找到一个绿色的锁形图标,如果连接是安全的。

语法
FirefoxProfile p=new FirefoxProfile(); p.setAcceptUntrustedCertificates(true);
示例
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class SSLErrorFirefox{
public static void main(String[] args) {
//DesiredCapabilities object
DesiredCapabilities c=DesiredCapabilities.internetExplorer();
//set FirefoxProfile
FirefoxProfile p=new FirefoxProfile();
// configure setAcceptUntrustedCertificates to true
p.setAcceptUntrustedCertificates(true);
System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe");
//configure this profile to browser
WebDriver driver=new FirefoxDriver(p);
//implicit wait
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//URL launch
driver.get("application url to be entered");
}
}
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP