Selenium中的Chromedriver和SSL证书 [英] Chromedriver in Selenium and SSL certificate
问题描述
我正在使用Selenium来测试具有HTTP Auth甚至现在具有SSL证书的网站.
I am using Selenium to test a web site which has HTTP Auth and now even SSL certificate.
作为HTTP基本身份验证的解决方法,我正在使用ChromeDriver- http://code.google .com/p/selenium/wiki/ChromeDriver 并打开格式为
As workaround for HTTP Basic Authentification I am using ChromeDriver - http://code.google.com/p/selenium/wiki/ChromeDriver and opening URLs in format
https://username:password@my-test-site.com
但是现在出于安全原因,需要在PC上安装客户端证书才能登录该应用程序.
But now from security reasons, Client certificate needs to be installed on PC in order to log into that application.
但是,ChromeDriver无法看到选择证书"提示,我什至无法将其切换为警报".
However, ChromeDriver cannot see the "select certificate" prompt and I even cannot switch to it as Alert.
有人解决了这个问题吗?
Did somebody solved this issue?
推荐答案
除了安装客户端证书之外,您还可以使用--ignore-certificate-errors
命令行开关告诉Chrome忽略不受信任的证书错误.
Instead of installing the Client Certificate you could just tell Chrome to ignore the untrusted certificate error using the --ignore-certificate-errors
command line switch.
为此,请如下创建您的ChromeDriver
实例:
To do this, create your instance of ChromeDriver
as follows:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
driver = new ChromeDriver(capabilities);
这篇关于Selenium中的Chromedriver和SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!