Search code examples
javascriptacceptance-testingcodeceptjs

How to open a new tab or window when using CodeceptJS


I am trying to create a test with CodeceptJS (using WebdriverIO helper) in which I first log in on site A and then open a new window(or tab) and log in on site B. By doing the second 'I.amOnPage() it just reuses the same browser window, but I want to open a separate window/tab and leave the site A active. Is this possible?

Update: I managed to open a new tab via I.executeScript("window.open();") however I am not managing to switch focus to the new tab via the switchTab() method from the WebDriverIO helper, since the following I.amOnPage() is directed to the previous tab rather than the newly opened one.


Solution

  • Solved it following https://github.com/Codeception/CodeceptJS/issues/252 . The switchTab() method needed a change due to a WebdriverIO API version difference.