1

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.

Garrarufa
  • 1,145
  • 1
  • 12
  • 29

3 Answers3

1

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.

flup
  • 26,937
  • 7
  • 52
  • 74
Petrogad
  • 4,405
  • 5
  • 38
  • 77
0

I cannot add comment but use xpath //table[@name="table_name"]/tbody/tr/td[1] in xpath selector to the linked question that Petrogad mentioned.

Ray
  • 1,539
  • 1
  • 14
  • 27
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

KFox112
  • 452
  • 4
  • 11