I have 30 rows in a table and I need to perform scroll twice or it may be thrice if rows increases in future. I am using each and store first 20 element with 1 scroll but the element I need will need one more scroll.
cy.get("row locator").each(($ele, index) => {
if (index > 9){
cy.get("scroll bar locator").scrollTo(1000, 1000).wait(0);
cy.get("row locator").contains(text).parent().parent()
.sibling().eq(1).click();
}
else{
cy.get("row locator").contains(text).parent().parent()
.sibling().eq(1).click();
}
});
If you want to repeat an action (like scrolling a table) until a condition is met, the cypress-recurse plugin is useful.
For example