gpt4 book ai didi

ruby - 无法使用 Watir 绕过 Firefox 的不安全证书警告

转载 作者:数据小太阳 更新时间:2023-10-29 08:26:06 24 4
gpt4 key购买 nike

在 Watir 6.2.0 中使用 Firefox 驱动程序时,我似乎无法忽略任何证书警告。这是意外行为,还是我没有正确使用 API?

示例代码:

require 'watir'

profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false

browser = Watir::Browser.new(:firefox, :profile => profile)

browser.goto 'https://self-signed.badssl.com/

意外结果:

/Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': Selenium::WebDriver::Error::UnknownError
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/default.rb:107:in `request'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/w3c_bridge.rb:620:in `execute'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/w3c_bridge.rb:126:in `get'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/navigation.rb:32:in `to'
from /Users/bshannon/.rvm/gems/ruby-2.4.0/gems/watir-6.2.0/lib/watir/browser.rb:78:in `goto'
from /Users/bshannon/Desktop/test.rb:8:in `<main>'

enter image description here

环境:

Watir 6.2.0
Selenium Webdriver 3.3.0
Geckodriver 0.15
Firefox 52.0
Mac OSX

最佳答案

您可以通过 desired capabilities 执行此操作. https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings#ssl-certificates 处有其他文档.

require 'watir'
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true)

browser = Watir::Browser.new(:firefox, :desired_capabilities => capabilities)
browser.goto 'https://self-signed.badssl.com/'
puts browser.url #=> https://self-signed.badssl.com/
browser.close

关于ruby - 无法使用 Watir 绕过 Firefox 的不安全证书警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42813799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com