Skip to content

Instantly share code, notes, and snippets.

@bahmutov
Created February 22, 2021 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahmutov/6f527fe62a2eeec76b49c343fa74163d to your computer and use it in GitHub Desktop.
Save bahmutov/6f527fe62a2eeec76b49c343fa74163d to your computer and use it in GitHub Desktop.
it('until the number 7 appears', () => {
const checkAndReload = () => {
// get the element's text, convert into a number
cy.get('#result').should('not.be.empty')
.invoke('text').then(parseInt)
.then((number) => {
// if the expected number is found
// stop adding any more commands
if (number === 7) {
cy.log('lucky **7**')
} else {
// otherwise insert more Cypress commands
// by calling the function after reload
cy.wait(500, { log: false })
cy.reload()
checkAndReload()
}
})
}
cy.visit('public/index.html')
checkAndReload()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment