Vadym
Vadym

Reputation: 11

Cypress. Get a list of opened tabs

Is it possible to make a list of opened tabs? The case is:

  1. I click on a button
  2. It generates the link and opens it in a new tab
  3. I have to navigate to this page and do some verifications

In case that Cypress does not support multi-tabs. It would be good to have a list of the opened tabs. So I can navigate to them.

Upvotes: 1

Views: 904

Answers (1)

Manuel Abascal
Manuel Abascal

Reputation: 6312

According to the official documentation, Cypress'll never have multi-tabs support. What you could do, however, for your test case is:

  • Check the links open in new tabs like so: cy.get('a[href="/index"]').should('have.attr', 'target', '_blank').

  • Visit the href like so: cy.visit('/index.html').

  • Assert the visited page's content.

If you need inspiration, you could use this recipe for handling tabs & links.

Upvotes: 1

Related Questions