electroncypressgoogle-signin

Cypress gives "This browser or app may not be secure" google auth


Image

Cypress. gaves this dialog after i entered login Email.

    it('Login via Google', function() {
    cy.visit(website + 'login')
    cy.get('a[href="/connect/google"]').click()
    cy.origin('https://accounts.google.com/', { args: [email, password] }, ([email, password]) => {
      Cypress.on('uncaught:exception', (err) => {
          if (err.message.includes('RPC executor service threw an error') ||
                  err.message.includes('ResizeObserver loop completed with undelivered notifications')) {
              return false
          }
          return true
      })
      function emailType() {
          cy.get('input[type="email"]').
              should('be.visible').
              type(email, { delay: 100 })
          cy.get('button')
              .contains('Next', { timeout: 10000 })
              .should('be.visible')
              .click()
          cy.wait(3000)
          passwordType()
      }
      function passwordType() {
          cy.get('input[type="password"]', { timeout: 30000 })
          .should('be.visible')
          .type(password, { delay: 100 })
          cy.get('button').
              contains('Next').
              should('be.visible').
              click()
      }
      emailType()
  })
  cy.url().should('include', website)

})

disabled:


Solution

  • try to prevents Chrome from revealing that it's being controlled by an automation tool like Cypress (index.js):

    --disable-blink-features=AutomationControlled

    also disable caches, by test everytime, caches saved.

    --disable-cache

    inside on('before:browser:launch', browser, launchOptions with argus.push

    noticed inside origin u didn't call clearLocalStorage to clear storage in ur origin while visit.

    with the same file if u need save login caches to call another test it() u will need after login google save session to retrive it. example.

      let Session= ''
    
      it('google login', function() {
          cy.getCookie('PHPSESSID').then((cookie) => {
          Session = cookie.value
          })
      }
    
      it('Check login', function() {
          cy.visit(website).then(() => {
              cy.clearCookie('PHPSESSID')
              cy.setCookie('PHPSESSID', Session).then(() => {
                  cy.getCookie('PHPSESSID').should('have.property', 'value', Session)
              })
            })
            cy.visit(website)
      })