aman_coder aman_coder - 1 year ago 135
Java Question

ALT+S key press using Robot Class not working when used along with Selenium

I am automating a scenario using Selenium Webdriver. When I click on the button using the selenium java script in IE, it downloads an excel file(shown in image-popup).
However I need to click on the "Save" option in that bar, so that it gets downloaded at the default location.
Since selenium does not provide the support for clicking the file download browser popup, so i have tried using robot class fuctionality.

The code which i have used is:

//some wait of 4 seconds

Code for clickOnSave():

Robot robot=new Robot();

However, this is not working as it is not able to click on the "save" option.
Please suggest

Answer Source

This issue was resolved with a minor change in the script. Instead of


use JavascriptExecutor as,

executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//*[@id='btnGenerateExtract']/span/span")));

Rest of the keyboard or mouse events could be performed using Robot class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download