I am working on an automated test that needs to open a document in Internet Explorer. The script works perfectly fine until after clicking a link to the document, which launches the pesky IE popup window like below
Since I am not able to focus on the window using Webdriver, I have tried to use Robot.java to send the keys "Alt+O", which works fine manually, but deadlocks at runtime while executing. My assumption is there is some incompatibility with Selenium/Robot.java but I'm stumped on this one as I am not able to generate any logs due to the deadlock. Please do not suggest using AutoIT as my security analysts will not let me use it for some silly reason. Any help is much appreciated.
Tooling:
- selenium-server-standalone-2.41.0
- IEDriverServer (32 bit version)
- Internet Explorer version = 9
- Script is written in Java
MyRobot.java
public class MyRobot {
private static Robot robot;
public static void sendVirtualKeyCombination(int... keyEvents) {
try {
robot = new Robot();
robot.setAutoDelay(1000);
// Press key combination
for (int keyEvent : keyEvents) {
System.out.println("Pressing " + KeyEvent.getKeyText(keyEvent));
robot.keyPress(keyEvent);
}
} catch (AWTException e) {
e.printStackTrace();
} finally {
// Release all keys
for (int keyEvent : keyEvents) {
System.out.println("Releasing " + KeyEvent.getKeyText(keyEvent));
robot.keyRelease(keyEvent);
}
}
}
}
MyRobot invocation
MyRobot.sendVirtualKeyCombination(KeyEvent.VK_Alt, KeyEvent.VK_O);