Cypress detects cross origin error on test that does not leave main origin

Viewed 171

I've been running into a problem with Cypress (currently v8.3.1 but this has been a constant for years) where my test detects a cross origin error on page load, but I am 99% certain that shouldn't apply.

The test logs into a web application and attempts to access a project.

cy.visit(webapp)                     //login page
cy.login(userCreds)                  //enter user cred and access main page
cy.get(projectAcccessButton).click() //access project from main

As the project page loads, Cypress throws the cross origin error below. I've been using the "chromeWebSecurity": false workaround, but it does not apply to Firefox. Firefox test coverage is on the "2022 To Do" list, so I am turning to Stack for answers - I hope.

What I want to do: Access the project page without issue.

What has been happening: cross origin error on page load

Permission denied to access property "document" on cross-origin object

I mentioned that the cross origin error likely shouldn't apply because when I modify the test to access the project page via cy.visit(), Cypress does not throw an error.

cy.visit(webapp)                     //login page
cy.login(userCreds)                  //enter user cred and access main page
cy.visit(projectPage)                //access project via url

This leads me to believe something is happening on the button click that is somehow triggering the cross origin error. Is it possible that the button attribute onclick="window.location.href='/projectManager/123456789'" is somehow being interpreted as leaving the main origin?

If this error is related to the window.location.href, how can I resolve this so Cypress doesn't detect an error when running in Firefox?

Full Error Message:

CypressError

0 Answers
Related