cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

Writing E2E tests is almost impossible due to the restriction while navigating to an integrated system #14616

Closed rakeshnambiar closed 1 year ago

rakeshnambiar commented 3 years ago

Current behavior

Writing E2E tests is almost impossible due to the restriction while navigating to an integrated system. Test flow:

Error message

Cypress does not allow you to navigate to a different origin URL within a single test.

Desired behavior

Other tools like Selenium or protractor support to interact with the elements on the newly navigated page.

Test code to reproduce

context('Login', () => {
    beforeEach( () => {
        cy.visit('https://europepmc.org/accounts/login')
        cy.get('#data-protection-agree').click()
    })

    it('Verify ORCID Login', () => {
        cy.get('#orcid--signin-button').click()
        cy.get('#username').type('xxxxx@gmail.com')
    })
})

Versions

"cypress": "^6.2.1"

Narretz commented 3 years ago

Well, this is one of Cypress' main and well documented drawbacks. You can work around this by diasbling webSecurity in Chrome. https://docs.cypress.io/guides/guides/web-security.html#Set-chromeWebSecurity-to-false

And the usual suggestion is to not test the login via the ui.

rakeshnambiar commented 3 years ago

Thanks @Narretz That helps .. I am from Protractor-selenium background and new to Cypress :)

rakeshnambiar commented 2 years ago

Hi @Narretz sorry for the delayed feedback. I tried this with the "chromeWebSecurity": false, and getting the below mentioned error. This is not just to test the login feature. Instead I need to claim an article after login to the ORCID as part of the E2E flow. I also found the external application where I have this issue is developed in angular 11.

Here's the UI flow in case you wish to take a look:

Please note, I am using the latest version 9.1.1

image

cypress-app-bot commented 1 year ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.