InterviewSolution
| 1. |
Explain methods to implement the Robot class in Selenium? |
|
Answer» Below are the few methods that help in the easy execution of test scripts required for Robot class implementation.
Let us understand these methods in details - Example : robot.keyPress(keyEvent.VK_UP); will press UP key on the keyboard.
Example: robot.keyRelease(keyEvent.VK_CAPS_LOCK); will release the pressed caps lock key on the keyboard.
Example : robot.mouseMove(coordinates.get.X(),coordinates.get.Y());will move the mouse over X and Y coordinates.
Example - robot.mousePress(InputEvent.BUTTON1_MASK); will press the mouse button
Example - robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); will release the right click of the mouse. Let us see the code on how to declare robot class - Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_DOWN); //will press down key on the keyboard robot.keyPress(KeyEvent.VK_TAB); // will press tab key on the keyboar |
|