0

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(); 
2
  • Please try with stackoverflow.com/a/50019382/9405154 Commented Dec 25, 2018 at 5:48
  • nope, this wont work as this opens in same window , it should open link in new tab Commented Dec 25, 2018 at 7:03

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.