-1

I am Automating web site using Web driver (Selenium)with Java,i need to do some download process (i.e XML file Download), let me know how will handle the Browser Popup (save As Dialog) using Java.

I am facing the same issue of IE download file popup so could you please share the steps how to do it:

enter image description here

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • What code have you tried? You can edit your question to include your code and the results when you run it (error or what it does that is different from what is expected). – Theresa Jun 04 '15 at 18:44
  • there is workaround, that allows to avoid interaction with confirmation popup https://stackoverflow.com/questions/48240146/selenium-download-file-in-internet-explorer-to-specified-folder-without-direct/48240157#48240157 this approach is quite bulky, but works fine for different cases – alex Jan 13 '18 at 13:27

1 Answers1

0

There is no way to control a "Save Dialog" dialog using Selenium only.

The common approach is to avoid it being opened in the first place and let the browser automatically save the file to the desired destination.

Here's an example code using Firefox webdriver:

FirefoxProfile firefoxProfile = new FirefoxProfile();

firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
firefoxProfile.setPreference("browser.download.dir", "/path/to/the/download/directory");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/xml,application/xml");

WebDriver driver = new FirefoxDriver(firefoxProfile);

Note that you have to specify the mime-types of the file you want Firefox to download automatically. In case of XML, text/xml and application/xml usually should be enough.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Application is behaving differently on diff browser when i tried to export the file on IE it opens the popup window which containing URL with .xml extension and rest of window is blank ...while on FF it is recognize with action class ....have u faced such behaviour ever ? – Kanhaiya Agrawal Jun 08 '15 at 04:30