1

I am trying to test my website from cypress.io, but i am constantly getting above error. I am facing issue will Signing in with google. I am using the cy.origin() method.

/// <reference types="cypress" />

describe('Basic tests', () => {

it.only('Login should happen', ()=>{
// cy.viewport(1280, 720)
cy.visit('https://internetcomputerservices.com')

cy.contains('Dashboard').click()
cy.contains('Sign in with Google').click()


cy.origin('https://accounts.google.com/o/oauth2/auth', ()=>{
   cy.get('[aria-label="Email or phone"]').click().type('haswrfbi20@gmail.com')
});

})

}) This is the image of the page after clicking "Sign in with Google"

Image of error

Please help me

yash
  • 77
  • 3
  • 10
  • Is there a way for us to reproduce this? – jjhelguero Oct 02 '22 at 00:46
  • `/// describe('Basic tests', () => { it.only('Login should happen', ()=>{ // cy.viewport(1280, 720) cy.visit('https://internetcomputerservices.com') cy.contains('Dashboard').click() cy.contains('Sign in with Google').click() cy.origin('https://accounts.google.com/o/oauth2/auth', ()=>{ cy.get('[aria-label="Email or phone"]').click().type('haswrfbi20@gmail.com') }); }) })` this is the code, i am testing site called, internetcomputerservice.com Please help! – yash Oct 02 '22 at 03:35
  • internetcomputerservices.com, i forgot the "s" after "service" – yash Oct 02 '22 at 04:01

1 Answers1

0

Although I haven't able to find the solution for testing google login, i have connected with team and they will most likely resolve this issue in cypress 10.10.0.

For meanwhile, you can use token to directly login, by-pass the google-login and test the website. you can find the token by going to developer tools and there you will find Application, click on it, there you will find the token, copy it and paste it in below code.

Make sure to install the package before hand:

npm i cypress-localstorage-commands

Code:

describe("Basic tests", () => {
  before(() => {
    cy.visit("---your-website-url---", {
      onBeforeLoad(win) {
        win.localStorage.setItem(
          "token",
          "---token-here---"
        );
      },
    });
  });
  it.only("should be able to run test 1", async () => {
    // write your first test here ----
  });
});
yash
  • 77
  • 3
  • 10