question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft login removes the Cypress test frame when it redirects, causing tests to fail

See original GitHub issue

Current behavior

Using 9.6.0, I want to use the origin function to firstly, login through Microsoft and then continue with the test within the baseUrl.

Using the code below, when cy.visit('/'); is executed, the test frame around Cypress (when using yarn cypress open) is removed and consequently, Cypress can no longer communicate with the browser and all tests fail.

describe('Authenticate', () => {
    beforeEach(() => {
        cy.origin('https://login.microsoftonline.com', () => {
            cy.visit('/');
            cy.get('[name="loginfmt"]').type(`${Cypress.env('email')}{enter}`);
            cy.get('[name="passwd"]').type(`${Cypress.env('password')}{enter}`);
            cy.get('[type="submit"]').type('{enter}');
        });
    });

    it('Show homepage once logged in', () => {
    });
});

Is there a working solution for this?

Desired behavior

For the Cypress test frame to persist whilst the login occurs.

Test code to reproduce

As above.

Cypress Version

9.6.0

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:8
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
AtofStrykercommented, Aug 9, 2022

@thecodeholic have you tried adding the new experimentalModifyObstructiveThirdPartyCode along side experimentalSessionAndOrigin as described here? It looks like you are being frame busted, which the experimentalModifyObstructiveThirdPartyCode should modify to get you up and running.

1reaction
thecodeholiccommented, Aug 10, 2022

@AtofStryker That was the case. Thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure AD Authentication in Cypress Tests
With Azure AD, the usual login flow is to check if the user has a valid token and if not, redirect them to...
Read more >
Error Messages | Cypress Documentation
We found an error preparing your test file. This message means that Cypress encountered an error when compiling and/or bundling your test file....
Read more >
While running the tests, cypress is redirecting - Stack Overflow
while I am running the tests in cypress, it is redirecting to login page, then remaining tests become fails . What is the...
Read more >
Cypress Best Practices For Test Automation - LambdaTest
Cypress is an amazing framework for testing your frontend applications. ... login page, which means you have failed the test in isolation.
Read more >
Using Cypress to test Azure Active Directory protected Single ...
Cypress is an all-in-one, end-to-end testing framework and assertion library ... authenticated and not redirecting the user to the Microsoft login page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found