Test Automation Stack

Say we have a List which shows users or Products and we need to validate if that list contains one of the Product, how can we do that ?

There are few ways, get the list and then use invoke(“text”) and then assert or use the .then function and loop through, but looping through might cost a bit of time.

We can leverage Chai’s .include function to check if the List contains the Value we are looking for.

Below code shows an example where I have names inside list of h1 and assertion using .include.

Note that if you want cypress to retry previous command incase of delay in loading use .should() instead of .then()

Leave a comment

I’m Gurudatt

Profile Pic

With over 12 years of quality assurance experience, i have used various test automation tools and testing concepts and helped organization and teams to speed up testing process effectively. I’m also a Cypress.io Ambassador and BrowserStack Champion.

Let’s connect

Discover more from Test Automation Stack

Subscribe now to keep reading and get access to the full archive.

Continue reading