Not Able to Download a File in IE Browser using Robot Class | Selenium Forum
M
Posted on 17/07/2016
I am trying to download a file in IE browser (version 10) and used Robot class to achieve the same but it doesn't seem to be working.
Below is the code.
driver.get("http://qtpselenium.com/test/testdownload.php");
driver.findElement(By.xpath("html/body/a[1]")).click();
Thread.sleep(2000);
Robot rb = new Robot();
rb.keyPress(KeyEvent.VK_ALT);
rb.keyPress(KeyEvent.VK_N);
rb.keyRelease(KeyEvent.VK_ALT);
rb.keyRelease(KeyEvent.VK_N);
rb.keyPress(KeyEvent.VK_TAB);
rb.keyPress(KeyEvent.VK_ENTER);

I also tried this:
rb.keyPress(KeyEvent.VK_ALT);
rb.keyPress(KeyEvent.VK_S);
rb.keyRelease(KeyEvent.VK_ALT);
rb.keyRelease(KeyEvent.VK_S);

But the file is not getting downloaded.

Could you please help me on this and let me know if something is wrong in the above code.

M
Replied on 18/07/2016

http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

http://stackoverflow.com/questions/29792415/how-to-download-a-file-from-ie-browser-using-webdriver-selenium