Why Robot framework in Selenium?

Why to use  Robot Class?

Because Selenium  is unable to Interact with operating system pop-ups or .exe Application So,Whenever there is a need to control keyboard or mouse to interact with OS windows like Download pop-up, Alerts, .exe applications like Notepad,Calculator, etc. Its required to use   “Robot  Class”.

It helps in downloading/uploading of file.

Robot  Class is preferred when it comes to automate the secure Application like Banking App,

Finance App etc.

Limitations/Precondition of Robot Class:

1.Methods like mouseMove is screen resolution dependent. So, keep the same resolution of display on production as well development environment.

2. Once mouse event occur , Screen should not change before the required action perform on mouse event.

3. You need to pay attention on the order of key release.

Some of the popular methods  are:
  • .keyPress();
  • .mousePress();
  • .mouseMove();
  • .keyRelease();
  • .mouseRelease();

a. .keyPress()


It will press Escape key on keyboard.

b. .keyRelease()


It will release the CAPS_LOCK key.

c. .mousePress()


It will press Left mouse button.

d. .mouseRelease()


It will release Left mouse button.

e. .mouseMove()

robot.mouseMove(coordinates.getX(), coordinates.getY());

It will move the mouse pointer to X and Y co-ordinates.

Exception in Robot class
Since Robot Class comes under AWT package, it throws AWTException.

 Robot robot;
 try {
        robot = new Robot();

      // Press Enter
     // Release Enter
    } catch (AWTException e1) {
Shashank Verma

Shashank is an information technology graduate, keen observer and a perfection seeker. Passionate about browser as well as Robotic Process Automation