gpt4 book ai didi

google-login - 任何人在使用 Google 登录的 cypress 中都有一个例子

转载 作者:行者123 更新时间:2023-12-04 11:49:05 27 4
gpt4 key购买 nike

我需要为我的应用程序编写一个使用联合登录 (Google) 的 cypress 测试。即使在我禁用了 chromeWebSecurity 之后,我仍然收到 CORS 错误。有没有人有任何示例代码?

describe('log in with google', ()=>{
it('should work', ()=>{
cy.visit('http://localhost:3000/')
cy.contains('Log in with Google').click()
cy.get("input#identifierId").type('gohawks12x3@gmail.com{enter}');
cy.wait(5000);
cy.get("input[@type=password]").type('<Pwd>{enter}');
})
})

谢谢!

最佳答案

有一个库叫cypress-social-login这就是这样做的。
它由 cypress 团队推荐,可在 cypress plugin page 上找到。 .

https://github.com/lirantal/cypress-social-logins

This Cypress library makes it possible to perform third-party logins (think oauth) for services such as GitHub, Google or Facebook.

It does so by delegating the login process to a puppeteer flow that performs the login and returns the cookies for the application under test so they can be set by the calling Cypress flow for the duration of the test.

关于google-login - 任何人在使用 Google 登录的 cypress 中都有一个例子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53487224/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com