Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Cypress.io test with Google Login popup window

Is it possible to login to a Google account with Cypress.io using the Google authentication pop-up window?

I can get the window to open, but then Cypress can't detect the ID for the email input field.

The error is: "CypressError: Timed out retrying: Expected to find element: '#identifierId', but never found it."

it('Login', function() {
    cy.visit('home')
    cy.get('#signin-button').click()
    cy.get('#google-login-button').click()
    // cy.wait(1500) // wait doesn't help
    cy.get('#identifierId')
    .type('[email protected]') // <<-- error here
  })
like image 703
beachCode Avatar asked Dec 14 '17 02:12

beachCode


People also ask

How does Cypress handle login pop up?

Browser Automation with Cypress and Gherkin 2022 Cypress can handle prompt pop-up windows, where users can input values. A prompt has a text field, where the input is taken. To handle a prompt pop-up, cy. window() method is used.

How do I run Cypress test in Chrome?

Chrome Browsers To use this command in CI, you need to install the browser you want - or use one of our docker images. By default, we will launch Chrome in headlessly during cypress run . To run Chrome headed, you can pass the --headed argument to cypress run .

How does Cypress interact with the browser?

It uses Sauce Labs (or another headless driver) to interact with browsers. Its API consists of commands that query for DOM elements, perform user actions, navigate around, etc. Cypress essentially replaces Capybara because it does all of these things and much more.


1 Answers

This does not work due to Cypress not having fully implemented iframe support.

However, Cypress does not suggest visiting 3rd party applications within your tests. There are many reasons for this including:

  • It is incredibly time consuming and slows down your tests.
  • The 3rd party site may have changed or updated its content.
  • The 3rd party site may be having issues outside of your control.
  • The 3rd party site may detect you are testing via a script and block you.
  • The 3rd party site may be running A/B campaigns.

Cypress has outlined the downsides to visiting 3rd party sites you do not control and some workarounds in their docs. I suggest reading the full explanation here.

like image 125
Jennifer Shehane Avatar answered Oct 20 '22 13:10

Jennifer Shehane