Brinda Sateesh
Brinda Sateesh

Reputation: 11

Iterate through each element in a particular column of a dynamic table using cypress

I have a dynamic table displayed based on a value selected from a radio button in my project. The radio button field "Doctor Name" field has different choices like "Frank", "Michael", "Josh", "Jessica". When I select the "Frank" value, it displays a dynamic table with the list of appointments for "Frank", The first column in the table is "Doctor Name". When I select "Frank" from the radio button, I have to validate if all the appointments listed are for "Frank". So I have to write coding in cypress to check if all the first column cell values are "Frank".


How can I achieve this?

Upvotes: 0

Views: 1248

Answers (1)

user16603697
user16603697

Reputation: 11

retrieve all the first columns using cy.get() with the proper selector, then use the each command to validate the content of each cell, something like this

cy.get("selector for first colums").each(($el, index, $list) => {
   cy.wrap($el).contains('Frank')
})

Upvotes: 1

Related Questions