5

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?

user2964961
  • 51
  • 1
  • 5

2 Answers2

1

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);
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
0

If its not a browser or windows menu ,If its a something like a web context menu you can use following code its in c# java must be similar

Actions actions = new Actions(WebDriver);
actions.ContextClick(webElement)
                                               .SendKeys(Keys.Down)
                                               .SendKeys(Keys.Down)
                                               .Build()
                                               .Perform();

you can use a combination of actions.ClickAndHold() and actions.MoveToElement() to create a drag effect , I use these to move portal widgets

Please tell me what type of menu you are working on

Anand S
  • 760
  • 5
  • 13
  • 28
  • Thank you for your answer. I'm not working on any menu, widget or button. I'm working on a 3D environment view like googleMap, I need to simulate pan, rotate and zoom using Mouse Right and Middle button. – user2964961 Nov 07 '13 at 14:46
  • This doesn't answer the question. contextClick() sends both a mouse down and mouse up. OP is asking for just mouse-down. It seems that this functionality does not exist and you have to use the Mouse class directly. – BadZen Jan 01 '15 at 15:37