There is currently no direct method provided by Selenium to achieve this task, so a workaround is necessary. If you are using Windows or Linux, the CTRL+T shortcut can be simulated as shown below; however, this method did not work for me:
browser.actions().keyDown(protractor.Key.CONTROL).sendKeys('t').perform();
Even when attempting to trigger it on a specific element:
$$('input').first().sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "t"));
The good news is that the following workaround does appear to be effective. You can customize the location.href
with the desired URL to open:
browser.driver.executeScript(function() {
(function(a){
document.body.appendChild(a);
a.setAttribute('href', location.href);
a.dispatchEvent((function(e){
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null);
return e;
}(document.createEvent('MouseEvents'))))}(document.createElement('a')));
});