I am using Nightwatch.js to write some System Tests. Now I want to loop through all elements of a table and check their values. How can I do this with Nightwatch.js? The table has a <tbody>
element containing several rows <tr>
. Every row has several columns <td>
. I want to get the values of every first <td>
element in every row.
Nightwatch.js loop through table
6k Views Asked by Garrarufa At
3
There are 3 best solutions below
0

Similarly, I wanted to iterate a table. More specifically, I wanted to iterate over the TRs, and then in the context of each TR, iterate over the TDs.
I found my answer here, as posted by kunal_bohra: NightWatch.js - get a list of child WebElements based on relative css locator
Take a peek at this answer here. This talks a bit about how you can use the selenium WebElements to navigate through the tree then check the value of each.
It's a bit goofy; but essentially you'll want to write a custom command which you can do through the nightwatch.js custom commands that navigates through the tree checking the values you're looking to resolve.