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.
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.
我无法添加注释,但可以在xpath选择器中将xpath //table[@name="table_name"]/tbody/tr/td[1]
用于Petrogad提到的链接问题。
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.