Handle multiple windows [new window/tab] in protractor

In one of earlier post, we have how to handle multiple windows or popups in selenium, this post will explain how to handle popups or new windows in protractor using typescript

Protractor gives a method getAllWindowHandles() which returns all the windows currently browser is holding.

and then we can access each window by using index, for e.g – index 0 determines the main browser windows and then rest follows



We will take a demo site , when you click on “New Browser” button, another window pops up.

so to test the scenario, we will 1st capture the main browser title, then navigate to child window and perform some action like get the child window title, you can navigate by using below line


then, we will return back to main window and get the title, so we can compare 1st title and last title, it should be same

Code – MultiWindows.ts

Change the conf.ts file specs to MultiWindow.js and run the test to see how we can navigate to different windows


Watch the demo here


Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *