Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver - How to Holds down the RIGHT mouse button?

Using Selenium 2.0 WebDriver (java), I need to test some navigation (rotate, pan...)

I need to be able to Holds down the RIGHT button while moving the mouse.

Similarly, I need to be able to holds down the MIDDLE button while moving the mouse.

It seems to be possible only with the LEFT button.

Actions actions = new Actions(driver);
actions.clickAndHold().perform();

Following question, i'm not dealing with any menu, button, widget but with a 3D Environment like GoogleMap where I need to simulate pan, rotate and zoom using MIDDLE button, RIGHT button and even Mouse wheel...

Any Help?

like image 941
user2964961 Avatar asked Nov 11 '22 18:11

user2964961


1 Answers

You can use robot class to perform same. For Right click use Button3 and for middle use Button2

Code for Right click

Robot robot=new Robot();
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);

Code for Middle Button

Robot robot=new Robot();
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
like image 186
Shubham Jain Avatar answered Nov 15 '22 03:11

Shubham Jain