繁体   English   中英

Watir:将自定义配置文件设置为watir firefox无法正常工作

[英]Watir: set custom profile to watir firefox not working

我找到了许多提示来实现自定义配置文件设置到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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM