java - Selenium WebDriver - Auto Download on Firefox -


i try automate download firefox, using selenium webdriver in java. unfortunately, have found lot of answers strangly not working in code.

i tried

profile.setpreference("browser.download.folderlist", 2); profile.setpreference("browser.download.manager.showwhenstarting", false); profile.setpreference("browser.download.dir", "d:\\"); profile.setpreference("browser.helperapps.neverask.openfile","application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream"); profile.setpreference("browser.helperapps.neverask.savetodisk", "application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream"); 

but impossible work! type of file try download csv excel file.

in mozilla>options>application, autorisation visible, despite setpreference added.

just before that, added

profile.setpreference("network.proxy.type", 1); profile.setpreference("network.proxy.http", "xxx.xxx.xxx.xxx"); profile.setpreference("network.proxy.http_port", xxxx); 

cause have proxy in company, time in mozilla>options>internet settings, proxy rules added visible.

i had same problem short time ago, code see 2 possibilities:

  1. the mime type not in list:

check this site if want list each application, maybe should include mime types excel files too. example:

application/excel application/vnd.ms-excel 
  1. disable browser.helperapps option:

add following option firefox profile, ensure disable download dialogue.

profile.set_preference('browser.helperapps.alwaysask.force', false) 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -