Reputation: 601
I have a table that looks like this -
<tbody>
<tr>
<td></td>
...
<td></td>
</tr>
</tbody>
The data in each cell is populated with a unique value from a json object, or a unique action takes place on it (ie check mark). The difficulty comes when a user can add additional rows with the same column count. How do I write an algorithm/function that will go through each cell and populate it with my unique json values or perform a specific action?
This is for Cypress QA Automation (Js/Ts). Each cell has a unique locator, but if I go that way, my page object model will have duplicate code.
Upvotes: 0
Views: 70
Reputation: 86
If you're fetching the data from a server, you'll have to build the table every time the data is fetched using a JavaScript function. I found an article that might be helpful: https://javascript.plainenglish.io/creating-a-dynamic-html-table-through-javascript-f554fba376cf.
Upvotes: 0