Today I learned a new topic called Robot Class and thought to share with you all.
Why Robot class?
We use this to control keyboard or mouse actions in OS windows like downloading, uploading, pop-up, alerts, print Pop-ups etc.
Why we need Robot class?
When we have to do any action in Webpage, we need a locator to perform the action. However, in OS windows we don’t have any locators to overcome this situation so we use Robot Class.
Benefits of Robot Class?
· Handles keyboard and mouse actions
· It helps in uploading/ downloading of files using selenium web driver
· It helps in managing pop-ups, alerts etc.
Common keys used in Robot Class are:
Down arrow key- robot.keyPress(KeyEvent.VK_DOWN)
Tab Key- robot.keyPress(KeyEvent.VK_TAB)
How to use Robot Class?
Instantiate the Robot class.
Robot robot = new Robot();
Give action which you required. Example given Below
Import the KeyEvent