Daniel Hao
Daniel Hao

Reputation: 4980

Best Cypress way to check if a tab has become 'active`?

Try to do a simple test on the new UI page. It has 2 tabs: tab-pay and tab-vaca. I could use cy.get(li:tab-vaca').focus() to get to this tab. How can I verify (assert) it's been in in active state then? And if possible, can I switch by toggle to one other tabs later? Thanks.

Upvotes: 0

Views: 3385

Answers (1)

Alapan Das
Alapan Das

Reputation: 18634

To check that the tab is diabled:

cy.get('li#tab-race > button').should('have.class', 'tab tab-inactive')

To go to either tabs:

cy.get('ul li').first().click() //go to gender tab
cy.get('ul li').next().click() //go to race tab

Upvotes: 2

Related Questions