Skip to content

Instantly share code, notes, and snippets.

@bahmutov
Created February 22, 2021 22:45
Show Gist options
  • Select an option

  • Save bahmutov/6f527fe62a2eeec76b49c343fa74163d to your computer and use it in GitHub Desktop.

Select an option

Save bahmutov/6f527fe62a2eeec76b49c343fa74163d to your computer and use it in GitHub Desktop.

Revisions

  1. bahmutov created this gist Feb 22, 2021.
    23 changes: 23 additions & 0 deletions page-reload-spec.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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()
    })