Webdriver implementation of the Download function, screen out the Windows Pop-up dialog box, Firefox settings browser properties, two ways to achieve:

Source: Internet
Author: User

First, use a new Firefox browser to open the Web app, the browser does not have any plug-ins, nor do any default configuration of the browser, but need to configure the browser properties

Get all the configuration files for a browser

Profilesini allprofiles = new Profilesini ();
"Selenium" is the profile created previously, with no plugins, and no default configuration for the browser
Firefoxprofile profile = Allprofiles.getprofile ("Selenium");
Set whether the Download progress box is displayed
Profile.setpreference ("Browser.download.manager.showWhenStarting", false);
Browser.download.folderList Set the default download folder for Firefox. 0 is desktop, 1 is "my download"; 2 is Custom
Profile.setpreference ("Browser.download.folderList", 2);
Set the browser's default download folder and path, and if you use a custom path, you must set Browser.download.folderList to 2
Profile.setpreference ("Browser.download.dir", "e:\\");
Set which type of file download does not ask for direct download
Profile.setpreference ("Browser.helperApps.neverAsk.saveToDisk",
"Application/zip,text/plain,application/vnd.ms-excel,text/csv,text/comma-separated-values,application/ octet-stream,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/ Vnd.openxmlformats-officedocument.wordprocessingml.document ");

Open a page with a new browser selenium
Webdriver Driver = new Firefoxdriver (profile);

Second, the use of plug-ins installed, the default configuration of the Firefox browser to open the Web app (that is, the browser itself is set to download the Windows dialog box does not pop up), completely do not need to do any configuration, only need to use the default browser to

Profilesini allprofiles = new Profilesini ();
"Selenium" is the profile created previously, with no plugins, and no default configuration for the browser
Firefoxprofile profile = Allprofiles.getprofile ("Default");

Browser Default to open page

Webdriver Driver = new Firefoxdriver (profile);

Webdriver implementation of the Download function, screen out the Windows Pop-up dialog box, Firefox settings browser properties, two ways to achieve:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.