ealeng
Menu
← All posts

Mar 5, 2020 · 1 min read

Cypress.io interacting with tables and lists

Often we get to a situation when we have a list, table or even div elements which have no way to differentiate one from another, here is an example: If you using WebDriver most likely you would…

test-automationjavascriptui-testing

Often we get to a situation when we have a list, table or even div elements which have no way to differentiate one from another, here is an example:

<tr>
<td class="centeralign"></td>
<td class="centeralign"></td>
<td class="centeralign"></td>
</td>

If you using WebDriver most likely you would use Xpath and call it the day. But what to do in Cypress? So in the example above we would need to click element based on the location, let say I want to click the second td element in the row, here is how to do it:

cy.get('tr>td').eq(1)    // Yield second 'td' in 'tr'

Cypress has really good documentation on how to use it in different ways

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.