Selenium 2 right click

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

I cannot right-click on a WebElement or elsewhere using coordinates. I also cannot move the mouse pointer.

I tried using the Actions object:

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

I also tried using the Mouse object:

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

These codes do not fail, but they do nothing.

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

Does anyone know what the problem is with this?

Thanks.

+6
source share
1 answer

Finally, I realized this problem.

In Selenium 2, the "contextClick" function above a web element does not simulate a right-click on this element, it simply fires the onContextMenu () event placed in the element’s HTML code.

So, if you want to access these context menus, it should be processed using HTML code.

+2
source

Source: https://habr.com/ru/post/900766/


All Articles