I have a small chat icon shown in all web pages. How to write in Cypress?
The small chat icon has class of Widget and it should be found in all pages.
I could write something like this below, but I wonder if there is any other way to get rid of repetitive should('have','Widget')
although, at this point I'm not even sure if using should('have','Widget')
is a correct practice but it works.
cy.get('.pageA').should('have.value', 'Widget')
cy.get('.pageB').should('have.value', 'Widget')
cy.get('.pageC').should('have.value', 'Widget')
cy.get('.pageD').should('have.value', 'Widget')
I am using Cypress with Cucumber Preprocessor.
If the assertions line up within a single test, you can take a data-driven approach
or if you want individual tests
A more concrete example from a Cypress tutorial,