I've encountered a challenge with Cypress tests while trying to log into the PayPal sandbox environment using cy.origin(). The issue arises after successful login when the tests get stuck at "Your tests are loading...". This problem occurs after the post-login redirection, and I'm seeking advice or solutions to overcome this hurdle.
Below is the relevant part of my Cypress code:
Cypress.Commands.add('handlePayPalCredential', () => {
cy.origin('https://www.sandbox.paypal.com', () => {
cy.fixture('checkout/session').then(({ paypalEmail, paypalPassword }) => {
cy.get('#email', { timeout: 10000 })
.should('be.visible')
.clear()
.type(paypalEmail as string) // Using paypalEmail directly from the fixture
cy.get('button[id="btnNext"]', { timeout: 10000 })
.should('be.visible')
.click()
cy.get('#password', { timeout: 10000 })
.should('be.visible')
.clear()
.type(paypalPassword as string) // Using paypalPassword directly from the fixture
cy.get('button[id="btnLogin"]', { timeout: 10000 })
.should('be.visible')
.click()
})
})
})
Once I'm redirected after logging in, Cypress seems to get stuck at "Your tests are loading..." without progressing further as expected.
What I've Attempted:
1- Ensuring that Cypress commands are properly chained and handling asynchronous operations correctly.
2- Adding explicit waits and assertions to verify elements on the redirected page.
3- Checking for any console errors or warnings that could explain the post-redirection behavior.
https://i.sstatic.net/dZxgE.png
Queries:
Has anyone faced a similar issue of Cypress tests getting stuck post-login, especially in scenarios involving cross-origin like PayPal?
Are there established workarounds or strategies to ensure Cypress can continue running tests after a login redirection to a different domain?
Any advice or recommendations would be highly appreciated. Thank you for your assistance in advance!