Can Robot class be used to handle mouse buttons in Selenium?

0 votes
Can Robot class be used to handle mouse buttons in Selenium?
Jul 15 in Selenium by Prerna
15 views

1 answer to this question.

0 votes

Hi Prerna, Yes you can handle mouse buttons using Robot class in Selenium Webdriver. Following automation script shows how you can imitate press and release of mouse buttons using Robot Class in Webdriver:

Robot robot = new Robot();

// Press Left button
robot.mousePress(InputEvent.BUTTON1_MASK);

// Release Left button
robot.mouseRelease(InputEvent.BUTTON1_MASK);

// Press Middle button
robot.mousePress(InputEvent.BUTTON2_MASK);

// Release Middle button
robot.mouseRelease(InputEvent.BUTTON2_MASK);

// Press Right button
robot.mousePress(InputEvent.BUTTON3_MASK);

// Release Right button
robot.mouseRelease(InputEvent.BUTTON3_MASK);
answered Jul 15 by Anvi
• 11,690 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
406 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
762 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
402 views
0 votes
1 answer
0 votes
1 answer

How selenium can be used in devops lifecycle?

Hey Catherine, as we know that a ...READ MORE

answered May 8 in Selenium by Anvi
• 11,690 points
37 views