[英]How do I use Cypress Origin with google accounts?
I am attempting to access a google service embedded into my website which uses accounts.google.com for the login.我正在尝试访问嵌入到我的网站中的谷歌服务,该服务使用 accounts.google.com 进行登录。
I'm trying to use the session/origin commands to do this, but it's failing as if I'm doing nothing at all.我正在尝试使用 session/origin 命令来执行此操作,但它失败了,就好像我什么都不做一样。 I use this with success to login to my application (non google login), but google seems to require something more.
我成功地使用它登录到我的应用程序(非谷歌登录),但谷歌似乎需要更多的东西。 I have spent a great deal of time browsing for answers with no luck
我花了很多时间浏览没有运气的答案
Code leading up to login:导致登录的代码:
cy.get('div [class="active carousel-item"]').find('button').first().click()
cy.loginGoogle(Cypress.env("GoogleUsername"),Cypress.env("GooglePassword"))
Login code:登录代码:
Cypress.Commands.add('loginGoogle', (username, password) => {
const args = { username, password }
cy.session(args, () =>
{
cy.origin('https://accounts.google.com', { args }, ({ username, password }) => {
cy.visit('https://accounts.google.com/')
cy.get('input[type="email"]').type(username)
cy.get('div[id="identifierNext"]').find('button').click()
cy.get('#login-password').type(password)
cy.get('#btn-login').click()
})
cy.visit('/')
cy.url().should('contain', 'mydomain.com')
})
})
尝试按照文档中的建议使用编程身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.