I am using Selenium WebDriver and Java and I need to automate the file upload feature. I tried a lot, but the moment the Browse button is clicked and a new window opens the
I think I need to add something to Alex's answer.
I tried to open the Open window by using this code:
driver.findElement(My element).click()
The window opened, but the driver became unresponsive and the actions in the code didn't even get to the Robot's actions. I do not know the reason why this happens, probably because the browser lost focus.
The way I made it work was by using the Actions selenium class:
Actions builder = new Actions(driver);
Action myAction = builder.click(driver.findElement(My Element))
.release()
.build();
myAction.perform();
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);