0

I have gone through the below link:

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

I know this task is easily possible by using Robot class in Selenium but the main disadvantage of Robot class is that: Keyword/mouse event will only works on current instance of Window. E.g. suppose a code is performing any robot class event, and during the code execution user has moved to some other screen then keyword/mouse event will occur on that screen.

Since my test suites are running on some virtual machine so this is not useful to me.I have to test pan operation on Right mouse button press and mouse middle button press.

Please provide a better solution for this other than Robot class because I have searched everywhere but m not getting a good solution.

Jasleen Kaur
  • 49
  • 1
  • 1
  • 5
  • You can use Action class to perform those opertion – Ankur Singh Sep 26 '18 at 15:17
  • How to use Action class in this context.Please provide some line of code so that I can understand. – Jasleen Kaur Sep 27 '18 at 06:26
  • @AnkurSingh I have used this code: builder.moveToElement(Element, StartPositionX, StartPositionY).contextClick().clickAndHold() .moveByOffset(OffsetPositionX, OffsetPositionY).release().build().perform(); But clickAndHold works only on Left mouse button – Jasleen Kaur Sep 27 '18 at 06:40

1 Answers1

0

Please try below code

Robot robot = new Robot(); 
robot.mousePress(InputEvent.BUTTON2_MASK); 
robot.mousePress(InputEvent.BUTTON3_MASK); 
Thread.sleep(5000);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
robot.mouseRelease(InputEvent.BUTTON2_MASK);
  • I have already mentioned above that I don't want to use Robot Class.Please provide some other solution than using Robot Class – Jasleen Kaur Sep 27 '18 at 06:25