Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
waqas973 opened this issue Oct 14, 2022 · 0 comments

Comments

@waqas973
Copy link

waqas973 commented Oct 14, 2022

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,
});
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant