6

I am using Selenium 2 (Web Driver) under Linux with a FireFoxDriver.

I am not able to perform a right click on a WebElement or on another possition using coordinates. I also cannot move the mouse pointer.

I have tried to use the "Actions" object:

Actions actions = new Actions(ffDriver);
WebElement we = ffDriver.findElement(By.linkText("WhatEver"))
actions.contextClick(we).build().perform();

I also have tried to use the "Mouse" object:

Mouse mouse = ((HasInputDevices)ffDriver).getMouse();
mouse.contextClick(we.getCoordinates());

These codes don't fail but they don't do anything.

However, if I perform a regular click in the two examples above, it works as expected.

Do anybody know what is the problem with this?

Thank you.

Angel Romero
  • 1,539
  • 2
  • 11
  • 16

1 Answers1

2

Finally I understood the issue.

On Selenium 2, the "contextClick" function over a web element does not simulate a right click into that element, it just activate the "onContextMenu()" event placed in the HTML code of the element.

So, if you want to access to that kind of context menus, it should be handled on the HTML code.

Angel Romero
  • 1,539
  • 2
  • 11
  • 16