When I open a new tab (second), I attempt to switch back to the first tab.
common.clickOpenNewSession(); //opens a new tab
browser.getAllWindowHandles().then(function (handles) {
var secondWindowHandle = handles[1];
var firstWindowHandle = handles[0];
browser.switchTo().window(secondWindowHandle).then(function () { //focus shifts to new tab
browser.sleep(3000);
expect(browser.driver.getCurrentUrl()).toContain("url");
//perform some actions
});
//the following does not work. I try to return to the previous tab without closing the second tab
browser.actions().sendKeys(protractor.Key.CONTROL).sendKeys(protractor.Key.TAB).perform();
browser.sleep(4000);
browser.driver.switchTo().window(firstWindowHandle);
browser.setLocation('http://google.com');
});