I need some help with the following loop:
localStorage.removeItem('DDFound');
cy.get(sel).each(($el, index, $list) => {
if(localStorage.getItem('DDFound')!='1')
{
cy.log(localStorage.getItem('DDFound'));
cy.wrap($el).click().then(()=> {
cy.get(table).then(elx => {
if(elx.find(tableitem).length > 0) {
cy.get(tableitem).click();
cy.get(lable).should('contain.text',"Item")
localStorage.setItem('DDFound','1');
}
})
});
}
});
I would like to break just after finding the right item(tableitem) and for that, I'm setting a localstorage (didn't find any other way) but it looks like cypress runs all items in each loop in parallel and not getting to the if(localStorage.getItem('DDFound')!='1')
after each element.