C# - Selenium - firefox 驱动程序无法捕获和应用 AcceptInsecureCerts(2018/02/08 最新版本)

标签 c# selenium firefox geckodriver

你好(第一次在这里发帖),

我无法让 geckodriver 绕过证书错误。我做了很多研究并确保我拥有所有组件的最新版本。我强调这一点的原因是因为该站点上存在的许多过去的问题都讨论过时的方法,例如使用 DesiredCapabilities。

这是我的代码:

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
FirefoxProfile profile = new FirefoxProfile("QA"){
    AcceptUntrustedCertificates = true
};
FirefoxOptions options = new FirefoxOptions(){
    Profile = profile
};
var driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://google.ca");

上面的代码失败了,我在 Firefox 上仍然收到证书错误。我在调试时注意到的一件事是驱动程序仍然将“acceptInsecureCerts”功能视为“假”。屏幕截图如下。

enter image description here

我做错了什么吗?请指教。

我目前正在使用:

  • Selenium V3.9(最新)
  • Mozilla Firefox Nightly 60.0a(最新)
  • geckodriver 19.1(最新)

最佳答案

啊!找到它:Firefox Options 有一个修复它的“addcapabilities”功能。

options.AddAdditionalCapability("acceptInsecureCerts", true, true);

关于C# - Selenium - firefox 驱动程序无法捕获和应用 AcceptInsecureCerts(2018/02/08 最新版本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48691513/

相关文章:

python - Selenium 如何在某些目标类中获取href的内容

javascript - 为什么我的网站上的导航栏会发生变化?

java - 更改浏览器选项卡时,从 Applet 打开的模型对话框位于 Applet 后面

javascript - JS : Cross Browser Compatibility - my JS works in chrome, 不在 FF 中

javascript - 在 C# cshtml View 中显示元组列表

node.js - 如何通过 NodeJS Selenium 驱动程序使用代理?

selenium - getAttribute 未返回 selenium 中样式的完整值

c# - 使用 Box.V2 API,DownloadStreamAsync 调用会导致文件损坏

c# - 在客户端添加 Gridview 新行

c# - 异常未在 Async/Await block 中捕获