How to close the current tab of the browser in protractor with out closing the complete browser

后端 未结 3 391
花落未央
花落未央 2021-01-12 13:45

In the application i have two options "Google , Twitter" . When i click on any option it will open in new tab.

In my test case , i would like to click on go

3条回答
  •  情书的邮戳
    2021-01-12 14:33

    You can try the following:

    Switch to the new opened tab. Close the current windows (in this case, the new tab). Switch back to the first window.

    browser.getAllWindowHandles().then((handles) => {
        browser.driver.switchTo().window(handles[1]);
        browser.driver.close();
        browser.driver.switchTo().window(handles[0]);
    });
    

提交回复
热议问题