I have a scenario where the text String in element could be either ‘Value exist in Queue’ or ‘Value doesn’t exist’
So I want to use should assertion to make sure any string of both is rendring properly.
I am trying these options but doesn’t work
cy.get("Attribute").should('include', 'Value exist in Queue' || 'Value doesn't exist')
Is there any work arround to tackle this situation.
2
Answers
Use
match
with a regular expression that matches either string.If you prefer to not use a regex,
cy.should()
allows you to pass in a function. So, we can pass in a function that uses chai’soneOf
method.Note: I left your
cy.get().should()
the same in terms of yielded subject, however, you may need to change$attribute
to$attribute.text()
.