I am experiencing an unusual issue in my protractor UI test. During one of the tests, I need to click on a link that opens in a new tab. The test passes when run individually, but fails when run as part of the test suite.
I would appreciate it if you could review the code and provide any suggestions for improvement.
function(callback){
browser.getAllWindowHandles().then(function(tabs){
var secondTab = tabs[1];
var firstTab = tabs[0];
browser.switchTo().window(secondTab).then(function(){
expect(browser.driver.getCurrentUrl()).toBe("www.google.com");
element(by.css('heading')).getText().then(function(text){
expect(text).toBe('Welcome');
});
browser.close(); //Close the current Tab
});
browser.switchTo().window(firstTab);
//Log Out from the site
element(by.id("side-menu")).click();
element(by.linkText("Logout")).click();
callback();
});
}