How to open link in new tab (JavaScript)

29 views
Skip to first unread message

Daniel Lidström

unread,
Sep 29, 2016, 10:02:00 AM9/29/16
to Selenium Users
I have a set of links that I wish to be opened in different tabs. I am going to go through all tabs and visually make sure I haven't broken anything so this is sort of a human automated test.
I thought it would be a good idea to use Selenium for this.
Here's what I'm trying to do:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder()
 
.forBrowser('chrome')
 
.build();

var baseUrl = 'http://xxx:5454/';

var links = [
 
"my/sold",
 
"my/payments",
 
"selling"
];

for (var i = 0; i < links.length; i++) {
  driver
.get(baseUrl + links[i]); // open link new tab somehow
  driver
.sendKeys(webdriver.Key.CONTROL + "t");
}


The above doesn't work of course, there's now sendKeys on driver. How can I achieve this with Selenium?

Thanks in advance!
Reply all
Reply to author
Forward
0 new messages