How do I handle Auth0 popup with Cypress?

180 Views Asked by At

I am writing e2e tests with Cypress for an app that uses auth0 for authentication.

From the documentation Cypress 12 supports this using the cy.origin command. My issue is when I click the login button, the origin command does not point to my new auth window command so I am unable to get the elements on that window.

PS. I know there is a cy.request option. I want to know if Cypress 12 supports this.

cy.visit('https://myapp.com');
cy.get("login_button").click()

cy.origin('https://accounts.google.com', () => {
cy.get('h1').should('have.text', 'Welcome')
  cy.get('#username').type('[email protected]');
  cy.get('input[type="password"]').type('testpassword', { log: false });
  // clicking submit does the auth and redirects back to main site
  cy.get('input[type="submit"]').click();
});

Cypress error screenshot

0

There are 0 best solutions below