-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

2
  • 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 4, 2015 at 18:44
  • there is workaround, that allows to avoid interaction with confirmation popup stackoverflow.com/questions/48240146/… this approach is quite bulky, but works fine for different cases
    – alex
    Jan 13, 2018 at 13:27

1 Answer 1

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.

1
  • 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 ? Jun 8, 2015 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.