在firefox中禁止不受信任的连接消息

在firefox中禁止不受信任的连接消息

本文介绍了Selenium Webdriver:在firefox中禁止不受信任的连接消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firefox中使用了Selenium Webdriver,但是我不知道是否是由于昨天更新了Firefox或网站上发生了什么变化,但是现在每次驱动程序打开页面时,我都会在Firefox中看到不受信任的连接页面,所以我会手动添加例外.

I've using selenium webdriver with firefox but I don't know if its due to firefox updating yesterday or something changing on the site but now everytime the driver opens the page I get the untrusted connection page in firefox so I would have to manually add the exception.

我无法授予该站点访问权以供其他人测试,因为它是我们正在创建的内部站点,但是firefox中的消息是:

I cannot give access to the site for others to test because it is an internal site that we are creating but the message in firefox is:

TestingSite使用了无效的安全证书.该证书不受信任,因为未提供颁发者链. (错误代码:sec_error_unknown_issuer)

TestingSite uses an invalid security certificate. The certificate is not trusted because no issuer chain was provided. (Error code: sec_error_unknown_issuer)

在测试中,我创建一个新的firefox配置文件并设置以下两个值:

In my tests I create a new firefox profile and set these two values:

f.setAcceptUntrustedCertificates(true);
f.setAssumeUntrustedCertificateIssuer(false);

我读到有关在其他人遇到类似问题的帖子上设置这些内容的信息,并且似乎在过去几个月中一直奏效,但现在我又再次遇到了例外,但仅限于此站点.

I read about setting these on other posts where people were having a similar problem and it seemed to have worked for the past few months but now I am getting the exception again, but only on this one site.

推荐答案

我也将硒3.0.0 Beta2与ff48.0.1一起使用也遇到了这个问题我尝试过的所有"API方式"都失败了,但是我找到了解决此问题的可行方法:

I got this issue as well using selenium 3.0.0 Beta2 with ff48.0.1All the "API-way" I've tried are failed, but I got a workable way to solve this issue:

步骤1-手动打开FF并手动接受自签名证书(我的意思是接受"sec_error_unknown_issuer"安全例外)

Step 1 - Open your FF manually and accept the self-signed certificate manually (I mean accept "sec_error_unknown_issuer" security exception)

第2步-找到FF的配置文件目录,并复制您的配置文件目录的路径,例如ex(MAC env):"/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"

Step 2 - Locate your FF's profile directory and copy the path of the your profile directory, ex(MAC env): "/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"

第3步-在您的Selenium Java代码中,使用以下方式初始化FirefoxDriver:

Step 3 - In your selenium java code, use the following way to init the FirefoxDriver:

FirefoxProfile firefoxProfile = new FirefoxProfile(new File("/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"));
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
FirefoxDriver driver = new FirefoxDriver(capabilities);

就是这样.您可以立即使用带有硒代码的自签名证书访问网站.整个想法不是使用硒API,而是使用FF的配置文件,该配置文件已经直接接受"sec_error_unknown_issuer"异常.这就是我解决此问题的方式,希望它可以对任何人有所帮助.

Then that's it. You can access the website with self-signed certificate using selenium code right now. The whole idea is not use the selenium-API, but use the FF's profile which is already accept "sec_error_unknown_issuer" exception directly. That's the way I solve this issue, hope it can help anyone.

这篇关于Selenium Webdriver:在firefox中禁止不受信任的连接消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:02