-2

How to handle Download dialog box in selenium webdriver for txt , excel ,word files without changing browser settings

hpuser
  • 1
  • 1
  • 1
  • 2
  • 1
    Provide part of code you've already tried. At least you should mention which browser (webdriver) and programming language you use – Andersson Apr 10 '16 at 08:50

2 Answers2

0

You can't do it without changing browser settings.

See this answer and linked answers there for how it can be done. Note that browser settings can be changed at runtime for the webdriver instance/window of the browser; it doesn't change the user's browser settings.

Community
  • 1
  • 1
aneroid
  • 12,983
  • 3
  • 36
  • 66
0

Let's assume you are using FireFox. If you don't want to change any setting in the browser, then you have to use Robot class for handling the dialog box.

Below code will do the job.

        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_S);

        robot.keyRelease(KeyEvent.VK_ALT);
        robot.keyRelease(KeyEvent.VK_S);
        Thread.sleep(5000); // sometimes there may be a delay for the dialog box to get appeared. Can be removed if needed
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);

Kindly share the code that you have tried to accomplish so that the community can assist you better.

Arul
  • 1
  • 1