2017-11-03 6 views
3

カスタムプロファイル設定をwatirファイアウォールブラウザに実装するヒントが多数見つかりましたが、すべて機能しません。Watir:カスタムプロファイルをwatirファイアウォールに設定しない

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の設定をカスタマイズすることは可能ですか?なにが問題ですか?

  • ワチールバージョン:6.0.2
  • セレンバージョン:3.0.1
  • ブラウザのバージョン:Firefoxの51.0.1
  • ブラウザのドライババージョン:geckodriver 0.11.1
  • OSバージョン:Ubuntuの16.04 0.3 LTSは

答えて

1

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 
+0

ありがとうございますが、これは機能しません。エラーメッセージ:未初期化定数Selenium :: WebDriver :: Firefox :: Options(NameError) –

+0

プロジェクトで「selenium-webdriver」が必要ですか? https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings#firefox –

+0

いいえ、私はワイアーしか必要ありません。私は "selenium-webdriver"を追加してテストしましたが、同じエラーメッセージが表示されます。プロファイル行を無効にすると、ブラウザは問題なく起動します。私はwatirが必要な場合は、セレン - webdriverを含める必要はないと思う。 –