lirantal / cypress-social-logins

Cypress authentication flows using social network providers
Apache License 2.0
248 stars 78 forks source link

Is there any way in which we can solve verify the code send by google using cypress-social-plugin for the first time #128

Closed waqas973 closed 3 months ago

waqas973 commented 2 years ago

I am using the cypress-social-plugin to automate google login using cypress. But the problem is whenever I put new google account credentials inside of cypress-social-plugin commands as mentioned in docs and try to run the test for the first time it say me to verify that it's you if I verify manually and run the test again then it does not ask me verification and test pass successfully. I want to know if the cypress-social-plugin has a solution for this. If it does then please give me a proper example of it.

Capture1

Here is code.

Commend.js Cypress.Commands.add("userLoginWithGmail", () => { const socialLoginOptions = { username: "some gmail here", password: "password here", headless: false, logs: true, cookieDelay: 2000, args: ["--no-sandbox", "--disable-setuid-sandbox"], getAllBrowserCookies: true, loginUrl: "https://some website URL/login", loginSelectorDelay: 3000, loginSelector: "a.auth0-lock-social-button.auth0-lock-social-big-button", postLoginSelector: "#drop-btn", }; cy.task("GoogleSocialLogin", socialLoginOptions).then( ({ cookies, lsd, ssd }) => { cookies.map((cookie) => { cy.setCookie(cookie.name, cookie.value, { domain: cookie.domain, expiry: cookie.expires, httpOnly: cookie.httpOnly, path: cookie.path, secure: cookie.secure, }); Cypress.Cookies.defaults({ preserve: cookie.name, }); }); cy.window().then((window) => { Object.keys(ssd).forEach((key) => window.sessionStorage.setItem(key, ssd[key]) ); Object.keys(lsd).forEach((key) => window.localStorage.setItem(key, lsd[key]) ); }); cy.log("login successful.");

  cy.visit(`/signup/new/`);
}

); });

Config.js

e2e: { setupNodeEvents(on) { // implement node event listeners here on("task", { pageLoadTimeout: 10000, GoogleSocialLogin: GoogleSocialLogin, }); },

lirantal commented 3 months ago

Going to close this for being stale but if any issues remain or more context to be shared, please comment and will re-open.