https://cypress.io logo
Login to gmail via cypress
# general-chat
m
I'm trying to implement solution for an interview where I have to login to gmail account and validate some checks from there. I'm able to login to gmail sing valid credentials but When I press next button after providing password, cypress runner returning this error for chrome browser. IF trying with electron then it stuck on loading. How we can resolve this issue and get access to mails. Login to google account accounts.google.com/ working fine. issue comes when you try to access gmail mails. Can anyone suggest any solution.
e
Im willing to bet that with the login attempts google has flagged that account, which is why you're seeing that error. Can you manually login with the same account?
You can see in the URL the user is getting redirected to a login challenge.
m
@echoing-tent-95037 Thankyou so much for your reponse.
@echoing-tent-95037 I tried to do it by creating a new account but facing same problem. And yes I' m able to login manually but it's not working via automation. Here i'm getting this error in console that block the frame . Which I investigated and knew that it's not allowed in javascript. So we can't login to gmail using cypress?
e
Cross origin isn't allowed in older versions of cypress, so you would need to use
cy.origin
within Cypress 12 or higher (I believe that's when cy.origin was allowed without making any config changes). The other thing you could do is handle the the login via requests in the before, then save the token needed in local storage and then continue with your test. You could try using something like this as well https://www.npmjs.com/package/cypress-social-logins
6 Views