I have some data tables with filters and sorting. Whenever I filter the data table with certain criteria the rows on the table change.
Let's say I have a user list in the data table and I filter users based on whether they are admin users or normal user, so if I select admin users with the filter drop-down, only admin users are shown.
Many of these kinds of filtering data changes do not reflect data table in any way other then data itself changes. Testing based on the data itself is not reliable because it is changing too fast.
What would be the best way to test that filtering/sorting is working properly?
One idea I had was to add data attributes to the table columns with the desired data and checking with web driver whether they satisfy the criteria.
<table>
<tr>
<th>User Id</th>
<th>Username</th>
<th>Email</th>
</tr>
<tr>
<td data-qa-user-type="admin">1</td> <!-- Note the data attribute -->
<td>Maria</td>
<td>[email protected]</td>
</tr>
</table>
<!-- Note the data attribute -->. I think thedata attributewill be key to your validation.