Sheenah
Sheenah

Reputation: 85

Right click in selenium webdriver problems

I've found this code here: https://stackoverflow.com/a/22376627/4165083

Actions oAction = new Actions(driver);
oAction.moveToElement(Webelement);
oAction.contextClick(Webelement).build().perform();  /* this will perform right click */
WebElement elementOpen = driver.findElement(By.linkText("Open")); /*This will select menu after right click */

elementOpen.click();

But I'm having problems with driver: "Cannot resolve symbol driver". I can't import anything. What should I do to get it working in my tests in Scala?

Upvotes: 0

Views: 715

Answers (2)

Giri
Giri

Reputation: 411

"Cannot resolve symbol driver" - Check have you created the instance of the WebDriver and is accessible.

For Actions class - import org.openqa.selenium.interactions.Actions; Provide complete code to assist.

Upvotes: 0

Saifur
Saifur

Reputation: 16201

I believe you are referencing to wrong element. You have to reference to the element you are trying to right click on;

WebElement elementToRightClickOn = driver.findElement(By.id("something"));
Actions oAction = new Actions(driver);
oAction.moveToElement(elementToRightClickOn);
oAction.contextClick(elementToRightClickOn).build().perform();  /* this will perform right click */
WebElement elementOpen = driver.findElement(By.linkText("Open")); /*This will select menu after right click */

elementOpen.click();

Upvotes: 1

Related Questions