After opening a new tab (second) I'm trying to switch to the first tab.
common.clickOpenNewSession(); //it opens the new tab
browser.getAllWindowHandles().then(function (handles) {
var secondWindowHandle = handles[1];
var firstWindowHandle = handles[0];
browser.switchTo().window(secondWindowHandle).then(function () { //the focus moves on new tab
browser.sleep(3000);
expect(browser.driver.getCurrentUrl()).toContain("url");
//do some actions
});
//below it doesn't work. I try to go back on 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');
});