使用Selenium进行自动化时,有没有办法抑制在HTTPS上访问网站时显示的警告?我遇到了“-trustAllSSLCertificates”选项,但我无法让它工作。我通过以下方式启动了Selenium服务器:
java -jar selenium-server.jar -trustAllSSLCertificates
...但我仍然收到安全警告。我错过了其他一些步骤吗?
答案 0 :(得分:6)
让它运转起来。方法如下:
除了使用-trustAllSSLCertificates
选项启动Selenium服务器之外,Selenium正在启动的浏览器应配置为使用Selenium服务器作为其代理。
例如:如果Selenium服务器在默认端口myselenium.mycompany.com
的主机4444
处启动,则代理设置为myselenium.mycompany.com:4444
。自动执行此操作的一种方法是创建Firefox配置文件并将代理配置到此地址和端口,并在使用-firefoxProfileTemplate
选项启动Selenium服务器时将此创建的配置文件作为参数传递。
java -jar selenium-server.jar -trustAllSSLCertificates -firefoxProfileTemplate /path/to/selenium_profile
答案 1 :(得分:4)
使用Selenium RC Server 2.X(表示版本2+),然后运行命令
java -jar selenium-server-standalone-2.X.X.jar -trustAllSSLCertificates
这是肯定的工作
答案 2 :(得分:0)
我一直在寻找一种程序化的方法来做到这一点,我有一个很好的方法来做到完全适合我的自动化框架。这是我的工作:
//==========Create a RC Configuratoion object and Set trust all SSL certs to true==========
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setTrustAllSSLCertificates(true);
//====Create a SeleniumServer object using the configuration=====================
SeleniumServer serv = new SeleniumServer(rcc);
serv.start