gpt4 book ai didi

ruby - Watir:将自定义配置文件设置为 watir firefox 不起作用

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

我发现了很多关于对 watir firefox 浏览器实现自定义配置文件设置的提示,但都不起作用。

隐私浏览设置:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.privatebrowsing.dont_prompt_on_enter'] = true
profile['browser.privatebrowsing.autostart'] = true
browser = Watir::Browser.new :firefox, :profile => profile

设置自动保存文件:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = path
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv"
browser = Watir::Browser.new :firefox, :profile => profile

错误信息:

/var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.1/lib/selenium/webdriver/remote/w3c_bridge.rb:80:in `initialize': unknown option: {:profile=>#<Selenium::WebDriver::Firefox::Profile:0x000000016da348 @model=nil, @native_events=false, @secure_ssl=false, @untrusted_issuer=true, @load_no_focus_lib=false, @additional_prefs={"browser.privatebrowsing.dont_prompt_on_enter"=>true, "browser.privatebrowsing.autostart"=>true}, @extensions={}>} (ArgumentError)

是否可以在 firefox 上自定义设置?怎么了?

  • Watir 版本:6.0.2
  • Selenium 版本:3.0.1
  • 浏览器版本:Firefox 51.0.1
  • 浏览器驱动版本:geckodriver 0.11.1
  • 操作系统版本:Ubuntu 16.04.3 LTS

最佳答案

在 options.profile 中分配您的个人资料

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = path
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv"
options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
browser = Watir::Browser.new :firefox, options: options

关于ruby - Watir:将自定义配置文件设置为 watir firefox 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47093958/

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