I'm jQuery from Cypress in writing a Cypress automated test. My objective is to do a search with no search criteria (we have several attributes that we can search on), then grab some attributes from the search results and do a search using some of those attributes. The second search should only return records that meet the search criteria of the second search.
Here's the code that attempts to do this:
cy.wait(5000);
let row = 0;
if (portRejectsResultSummary.cellExists('sequence-row-' + row)) {
do {
//loop until we find a row that has the instrument id set
if (portRejectsResultSummary.cellExists('instrumentIds-row-' + row)) {
let expectedInstrumentId = portRejectsResultSummary.getCell('instrumentIds-row-' + row).text();
portRejectsSearchFilters.instrumentIdInputField(expectedInstrumentId);
portRejectsSearchFilters.searchButton();
cy.wait(5000);
for (let i=0;i<100 && portRejectsResultSummary.cellExists('sequence-row-' + i);i++) {
portRejectsResultSummary.verifySummaryInstrumentIdCellData(i, expectedInstrumentId);
}
return;
}
row++;
} while (row < 100 && portRejectsResultSummary.cellExists('sequence-row-' + row));
}
The Cypress and Cypress.$ calls happen from those cellExists and verifySummaryInstrumentIdCellData methods. The problem is that in that inner for loop, cellExists continues to return true, even if there are no more search results from the second search, because jQuery is still seeing the values from the first search, which returned all records.
Any thoughts on why jQuery doesn't have access to the latest dom? This is a one page web application.