Selenium 和 SSL 证书中的 Chromedriver [英] 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 并以格式打开 URL
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 和 SSL 证书中的 Chromedriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!