Context click in Selenium 2.2
Got problem with opening custom context menu using advanced user interactions API in Selenium 2 (http://code.google.com/p/selenium/wiki/AdvancedUserInteractions).
Here is C# code:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.flickr.com/photos/davidcampbellphotography/4581594452/");
IWebElement photoDiv = driver.FindElement(By.Id("photo"));
Actions actions = new Actions(driver);
var context = actions.ContextClick(photoDiv).Build();
context.Perform();
Still this code doesn't open context menu but simply clicks on the image.
Still many other interactions work fine, like those at this blogpost.
I'm using Firefox 5 on Windows XP, Selenium version 2.2.
Thanks i开发者_如何学Pythonn advance for any suggestions how to make it work.
UPDATE: However, the code from here does the same (left click instead of context click).
ILocatable loc = (ILocatable)photoDiv;
IMouse mouse = ((IHasInputDevices)driver).Mouse;
mouse.ContextClick(loc.Coordinates);
mouse.MouseMove(loc.Coordinates, 15, 15);
Looks like a bug.
Have you tried using a robot click, Although they're not the most efficient way of doing so, but as long as the browser window is the top window it'll click the co-ordinates you set
Robot robot = new Robot();
robot.mouseMove(650, 590);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Maybe this will help you :-)
This seems to be that bug. It is stated in the user group here, though the bug is about double click.
精彩评论