Last active
June 21, 2023 11:54
-
-
Save ajdinmust/bddb5fd5c62baae436e6e32eaf68fa52 to your computer and use it in GitHub Desktop.
Recursive function for Cypress that reloads window if the element/text is not found when the page is visited.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findTag(retries = 0) { | |
return cy.get('mention-tags').then((mention) => { | |
if (!mention.text().includes(tagName) && retries < maxRetries) { | |
cy.log(`Tag name element not found! Retry number: ${retries + 1}`); | |
cy.reload(); | |
findTag(retries + 1); | |
} else if (retries === maxRetries) { | |
throw new Error(`Tag name element not found after ${retries} retries.`); | |
} else { | |
onFeedPage.elements.tagOnMention().should('contain', tagName); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment