Opening a link in a new tab in Chrome browser is not working in Selenium 3.4.0

38 views
Skip to first unread message

shre...@gmail.com

unread,
Nov 23, 2017, 11:02:19 PM11/23/17
to Selenium Users
I am trying to find a link in the page and open it in a new tab and for some reason this isn't working (fyi - My config details are given a the end of the message)

For instance, just open google.com and try to click 'Images' link at the top right and open it in a new tab with the code something like below:

------------------

String baseUrl = "http://www.google.com";
driver.get(baseUrl);

//Tried below 2 options, but none seems to be launching the Images in the new tab
driver.findElement(By.xpath("//a[text()='Images']")).sendKeys(Keys.CONTROL + "t");
driver.findElement(By.xpath("//a[text()='Images']")).sendKeys(Keys.chord(Keys.CONTROL, "t"));

//Even a simple create new tab using below is not working
new Actions(driver).sendKeys(Keys.chord(Keys.CONTROL,"t")).build().perform();

------------------

My config:
WebDriver version: 3.4.0
Chrome Driver: 2.3.3
OS: Windows 7 professional
IDE/Language: Eclipse/Java

Any pointers on getting this to work is much appreciated. Thanks!
Reply all
Reply to author
Forward
0 new messages