Skip to main content

Cypress reload Command

Cypress reload command reloads the web page.

Syntax

cy.reload()
cy.reload(forceReload)
cy.reload(options)
cy.reload(forceReload, options)

Arguments Used In Reload Command

  • force-reload: This argument reloads the page without using the cache. True forces the reload without cache.
  • Options: Log: To display the command in the command log. Timeout: Wait for some particular thing to get finished before timing out.
  • The reload command must be chained off with only cy.
  • It requires the response type to be content-type: text/HTML.
  • It requires the load event to fire.
  • cy.reload automatically waits for assertions that's chained to pass.

Reload Correct Use:

cy.reload()

cy.reload() yields the window object after the page reloading.

Let us take a look at some of the examples with  arguments:

describe('Automate AutoPract',()=>{
    it('Should load the url',()=>{
        cy.visit('http://www.autopract.com/#/home/fashion')
        cy.reload()   
    })

This will reload the page autopract.

describe('Automate AutoPract',()=>{
    it('Should load the url',()=>{
        cy.visit('http://www.autopract.com/#/home/fashion')
        cy.reload(true)
        
    })

This will force reload the page without cache as the true argument is passed inside.

Tags
Submitted by arilio666 on February 10, 2022

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.