1
我試圖用新Watir 6.0下載CSV文件。我找到了Firefox的配置文件設置:如何使用Watir 6.0下載文件
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = path_to_download
profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv"
browser = Watir::Browser.new :firefox, :profile => profile
但Firefox 50.0不支持加載配置文件設置。我得到這個錯誤信息:
/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
我也試過配置文件設置爲Chrome:
profile = Selenium::WebDriver::Chrome::Profile.new
profile['download.prompt_for_download'] = false
profile['download.default_directory'] = path_to_download
browser = Watir::Browser.new :chrome, :profile => Profile
,但該文件將不會被保存,文件保存對話框將不關閉。
所以這兩個都不適用於新的Watir。有沒有人知道用Watir下載文件的方法?
有也possibilty更改情景模式設置,顯示在瀏覽器中的內容,而不是打開一個下載對話框? –
在谷歌Chrome 55.0.2XXX和gnomedriver 2.25下,它不起作用。文件保存對話框將打開並且不會關閉,也不會保存文件。 –