0

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?

Community
  • 1
  • 1
Sheenah
  • 85
  • 12

2 Answers2

1

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();
Saifur
  • 16,081
  • 6
  • 49
  • 73
  • Alright, the problem was a little different that that with the "Cannot resolve symbol driver" but now, with similar code, I can't get "Actions" to create. I get: Cannot resolve constructor Actions. Any ideas why? – Sheenah Mar 11 '15 at 14:17
  • Have you instantiated the `driver` properly? Like `driver = new ChromeDriver();` or something before – Saifur Mar 11 '15 at 15:06
0

"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.

Giri
  • 411
  • 2
  • 18