gpt4 book ai didi

ruby - 错误 : disable image loading on watir with firefox

转载 作者:太空宇宙 更新时间:2023-11-03 18:08:02 24 4
gpt4 key购买 nike

我在更改 watir-webdriver 的配置文件时遇到错误。我使用以下代码来禁用在 firefox 中加载图像:

profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
profile['permissions.default.image'] = 2
browser = Watir::Browser.new :firefox, :profile => profile

出现此错误消息:

/var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/w3c_bridge.rb:80:in `initialize': unknown option: {:profile=>#<Selenium::WebDriver::Firefox::Profile:0x00000000e90700 @model="/home/amvisor/.mozilla/firefox/9ud9suhs.default", @native_events=false, @secure_ssl=false, @untrusted_issuer=true, @load_no_focus_lib=false, @additional_prefs={"permissions.default.image"=>2}, @extensions={}>} (ArgumentError)
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/firefox/w3c_bridge.rb:34:in `initialize'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/common/driver.rb:49:in `new'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/common/driver.rb:49:in `for'
from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver.rb:82:in `for'
from /var/lib/gems/2.3.0/gems/watir-webdriver-0.9.3/lib/watir-webdriver/browser.rb:46:in `initialize'
from xxx.rb:38:in `new'
from xxx.rb:38:in `<main>'

什么意思:

initialize: unknown option: {:Profile

有人可以帮忙吗?谢谢!

最佳答案

这适用于将现有的 Firefox 配置文件用于 Firefox 48+:

profile = Selenium::WebDriver::Zipper.zip('/path/to/profile/xxx.default')
caps = Remote::Capabilities.firefox(firefox_options: {profile: profile})
browser = Watir::Browser.new :firefox, desired_capabilities: caps

Ruby 绑定(bind)尚未完全支持新 geckodriver 中旧 Firefox 驱动程序的 Firefox 配置文件的所有功能。如果您需要这些附加功能,您可以使用 Firefox <48(我建议安装扩展支持版本)并传入 marionette: false 功能。

关于ruby - 错误 : disable image loading on watir with firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40527178/

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