Search code examples
seleniumwebdriver-io

Expect window.open in WebdriverIO?


Is it possible listen for a popup triggered with window.open? I don't care about whats inside the window, I just want to expect it to open. In Cypress it would be something like this

cy.window().then((win) => {
  cy.stub(win, 'open', () => {}).as('popup');
});

button.click(); // triggers the `window.open`

cy.get('@popup').should('be.called');

I can't quite find something like this for WebdriverIO.


Solution

  • browser.getWindowHandles().length
    

    this will give number of windows or tabs opened currently . use length >1 to validate window is opened