Problem Statement
I am using Selenium 3.14, Mac OS and Chrome version 71.0.3578.98 for my automation.
I tried this simple way: go to www.google.com and then right click on Gmail link and select on "open link in new window", but it's not happening :(
I have tried 2 options, both are not working, meaning the first option is not getting selected
I tried with the Robot class, but am unable to click "open link in new window" -- the Action Class is not working as expected.
Option-1
WebElement element=driver.findElement(By.linkText("Gmail"));
Point p = element.getLocation();
int x = p.getX();
int y = p.getY();
System.out.println(x+":"+y);
Robot r=new Robot();
r.mouseMove(1115, 19);
r.mousePress(InputEvent.BUTTON3_MASK);
r.mouseRelease(InputEvent.BUTTON3_MASK);
r.keyPress(KeyEvent.VK_DOWN);
r.keyRelease(KeyEvent.VK_DOWN);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
Option-2
Actions action= new Actions(driver);
action.contextClick(element)
.sendKeys(Keys.ARROW_DOWN)
.sendKeys(Keys.ENTER)
.perform();