Handling OS Window Apps in Selenium
In Selenium at times we need to control some OS windows such as Alerts/ Notepad/ Calculator/ Download Popup etc.
As we know selenium doesn't work with OS apps it works only in browser. So for this there is a class in JAVA which can be used with selenium to intract with this OS Apps.
Robot class methods can be used to interact with keyboard / mouse to handle OS apps while doing automation using selenium.
Syntax:
Robot robot = new Robot();
//This will press arrow UP key in keyboard
robot.keyPress(KeyEvent.VK_UP);
//This will press Right click on mouse
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK)
//This will hover mouse to the selected point on x,y coordinate.
robot.mouseMove(point.getX(), point.getY())
//This will press Enter on keyboard
robot.keyPress(KeyEvent.VK_ENTER))
//This will press Tab on keyboard
robot.keyPress(KeyEvent.VK_TAB))
There many other useful methods but this are common whileinteracting with OS apps.
So just use this in your Selenium code and interact with OS Apps.
We can use AutoIT too but it can only be used in Windows and we need to run our code across any OS.