PrakashFrancis
PrakashFrancis

Reputation: 191

Right click without Actions in Selenium 3.x in Firefox browser

How to right click an element without using Actions object. I get exception while using Actions in Selenium3 in FireFox with GeckoDriver. I have used the following code to set the GeckoDriver property.

System.setProperty("webdriver.gecko.driver", new File("lib/geckodriver").getAbsolutePath());

Upvotes: 0

Views: 482

Answers (2)

Anuj Teotia
Anuj Teotia

Reputation: 1323

Try using Robot class to right click on WebElement:

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_ENTER);

and to set the system properties for gecko driver you can use the below line :

System.setProperty("webdriver.gecko.driver", path of your geckodriver.exe");

Upvotes: 1

Bob Rivers
Bob Rivers

Reputation: 5441

Post the exception and detail which versions you are using (driver and FF).

Meanwhile, take a look at this post. At it, the problem was related with a driver problem.

Upvotes: 1

Related Questions