Firefox 4 with watir web browser: need help with helperApps.neverAsk to save CSV without prompt

I learned how to use Firefox 4 using watir and webdriver (on Win7 x64) by setting profile parameters. Example:

profile = Selenium::WebDriver::Firefox::Profile.new profile["browser.download.useDownloadDir"] = true profile["browser.download.dir"] = 'D:\\FirefoxDownloads' profile["browser.helperApps.neverAsk.saveToDisk"] = "application/csv" driver = Selenium::WebDriver.for :firefox, :profile => profile browser = Watir::Browser.new(driver) 

What I'm trying to do with the example below is that CSV files are always loaded into a specific directory that never opens. In the above code, it is possible to install all the files automatically downloaded to the specified directory, but installing browser.helperApps.neverAsk.saveToDisk has no effect: I still get the open / save question. After running the script, the Firefox window is still open, and I enter the URL: config. I see that browser.helperApps.neverAsk.saveToDisk was correctly installed in application.csv , but in firefox / options / options / applications I do not see entries for CSV files. It seems that setting the menu, which is really effective, is not really related to setting about: config. What am I doing wrong?

+4
source share
2 answers

I checked this for you, unfortunately, there is no standard content type for CSV files. You can try passing a comma-separated list of content types, and hopefully one of them works for you. For me it was an application / octet stream that did the trick ...

 require 'watir-webdriver' require 'selenium-webdriver' profile = Selenium::WebDriver::Firefox::Profile.new profile["browser.download.useDownloadDir"] = true profile["browser.download.dir"] = '/tmp' profile["browser.helperApps.neverAsk.saveToDisk"] = "text/plain, application/vnd.ms-excel, text/csv, text/comma-separated-values, application/octet-stream" driver = Selenium::WebDriver.for :firefox, :profile => profile browser = Watir::Browser.new(driver) browser.goto "http://altentee.com/test/test.csv" 
+11
source

In Firefox 6+, I could not get this to work without setting the value to "browser.download.folderList":

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

See: http://watirwebdriver.com/browser-downloads/

+4
source

Source: https://habr.com/ru/post/1345719/


All Articles