lundi 21 décembre 2020

Cypress get length of a table dynamically

I'm trying to test the length of a react table.

In particular I would want that after a user add a new row to the table it's length would increase by one

In my code I can't extract the length value of the table and save it in the variable rowsLength so that it can be checked later, what am I doing wrong?

It seems rowsLength is an object not a number..

const rowsLength = cy.get(".MuiTableBody-root").find("tr").its("length");

cy.get("#addRowButton").click();//new tr inserted

cy.get(".MuiTableBody-root").find("tr").should("have.length", rowsLength + 1);

enter image description here

Aucun commentaire:

Enregistrer un commentaire