I'm using Selenium WebDriver to automate a web browser, but I have a test case in which I need to save a pdf. Inspired by the methods employed in these two questions question 1 question 2 I have got the "Save As" to pop up with a java Robot object and pressed control + s by:
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_CONTROL);
This works great; however, when I try to type a location in the save to box and press enter with this code:
robot.keyPress(KeyEvent.VK_P);
robot.keyRelease(KeyEvent.VK_P);
robot.keyPress(KeyEvent.VK_O);
robot.keyRelease(KeyEvent.VK_O);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_C);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
it doesn't do anything. How come I can't type POC in the save to box and press enter using the same technique when it clearly has the focus?