Skip to content

Instantly share code, notes, and snippets.

View ajdinmust's full-sized avatar

Ajdin Mustafic ajdinmust

  • Mediatoolkit
View GitHub Profile
@ajdinmust
ajdinmust / reloadWindowRecursion.cy.js
Last active June 21, 2023 11:54
Recursive function for Cypress that reloads window if the element/text is not found when the page is visited.
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);