How can I check if an element contains multiple items in Cypress.io without replicating my code so much?
Current Example:
cy.get(".column")
.children()
.contains("Name");
cy.get(".column")
.children()
.contains("Age");
cy.get(".column")
.children()
.contains("Weight");
cy.get(".column")
.children()
.contains("Height");
cy.get(".column")
.children()
.contains("Favorite Color");
You can do it in this way:
cy.get('.column')
.children()
.should('contain', 'Name')
.and('contain', 'Age')
.and('contain', 'Weight')
.and('contain', 'Height')
.and('contain', 'Favorite Color')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With