3

The javascript in the page of application under test makes use of location.href='Dashboard.aspx'. Running a test against this page is making the url call to get /__/Dashboard.aspx.

I have witnessed this also in Firefox. I notice that there is a bug logged #5099 on github which is similar but not exactly the same. How to test a website page made in this fashion? What is suggested solution?

I did manage a workaround to monitor the ajax call and then, once returned, tell Cypress to call the Dashboard page but this is not testing the redirect logic, and what if the JavaScript has multiple pages that could be called depending on the result of the ajax request?

cy.server()
cy.route('POST', '/Login').as('login')
...

cy.wait('@login').then((xhr) => {
    if (xhr.status == 200)
    {
        cy.visit('Dashboard/Dashboard.aspx')
    }
})

What is the way so that code in the website using location.href just works?

  • Can you put a link on your question to the bug in github so that we can see more info on the problem? There is another [issue on github #7509](https://github.com/cypress-io/cypress/issues/7509) – Timo Aug 07 '22 at 05:59

0 Answers0