0

I am trying to get the second tab in my window browser by using below code but it is not working for me. Can any one suggest me easy way.

browser.getAllWindowHandles().then(function (handles) {  
  //Code for switchTo one Tab to another Tab in Same Browser
  browser.switchTo().window('http://localhost:4200/home-unauth'); 
});
HaC
  • 902
  • 12
  • 24
Akhil
  • 11
  • 1
  • 8
  • You can refer this answer https://stackoverflow.com/a/29505926/5042982. You capture all window handles after resolving the promise and then switch back to initial handle i.e. handle[0]. – AKJ Nov 21 '17 at 00:24

1 Answers1

-1

Resolved promise of getAllWindowHandles returns an array of tabs uuid. You even don't need to decode the values; new tab is added as last parameter of that array.

Try that - switch to second tab:

return browser.getAllWindowHandles().then((allTabs) => {
   return browser.switchTo().window(allTabs[1]);
});
Kacper
  • 1,201
  • 1
  • 9
  • 21