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, 2019 in Selenium by Prerna
76 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, 2019 by Anvi
• 14,110 points

Related Questions In Selenium

0 votes
1 answer

Which methods which can be used to handle pop-up and alerts in Python Selenium Webdriver?

Hey Kishor, Python Selenium webdriver provides following ...READ MORE

answered Jul 29, 2019 in Selenium by Abha
• 27,930 points
102 views
0 votes
1 answer
0 votes
1 answer

Which click command can be used to click on a specific part of webpage in Selenium?

Hi Apeksha, in Selenium IDE to click on ...READ MORE

answered Oct 17, 2019 in Selenium by Devesh
266 views
0 votes
2 answers

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,510 points
3,555 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,564 views
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,890 points
2,611 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,898 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, 2019 in Selenium by Anvi
• 14,110 points
776 views