Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

Is there a way to physically close a tab via Protractor or WebDriver?

I ask because while I know how to switch tabs programmatically, but it does not bring the active tab to the foreground. I can't always tell what is going on in my E2E tests that run on SauceLabs because when I view the screencasts it is showing the tab that I navigated away from, not the active one.

Am I going about this incorrectly?

it('should do something in the previous tab', function(done) {

    browser.getAllWindowHandles().then(function (handles) {


        // do something





1 Answer

0 votes
by (62.9k points)

You will have to switch to the newly opened tab and close the current windows (here, the new tab). Switch back to the first window.

 browser.getAllWindowHandles().then(function (handles) {





Hope this helps!

Browse Categories