Reputation: 85
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
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
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