Watir: set custom profile to watir firefox not working

734 Views Asked by At

I found many hints to implement custom profile settings to the watir firefox browser, but all don't work.

Setting for private browsing:

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

Setting for auto save file:

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

Error message:

/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)

Is it possible the customize the settings on firefox? What is wrong?

  • Watir Version: 6.0.2
  • Selenium Version: 3.0.1
  • Browser Version: Firefox 51.0.1
  • Browser Driver Version: geckodriver 0.11.1
  • OS Version: Ubuntu 16.04.3 LTS
1

There are 1 best solutions below

6
Safi Nettah On

Assign your profile in 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