6

是否可以使用 Google 身份验证弹出窗口通过 Cypress.io 登录 Google 帐户?

我可以打开窗口,但赛普拉斯无法检测到电子邮件输入字段的 ID。

错误是:“CypressError:重试超时:应找到元素:'#identifierId',但从未找到它。”

it('Login', function() {
    cy.visit('home')
    cy.get('#signin-button').click()
    cy.get('#google-login-button').click()
    // cy.wait(1500) // wait doesn't help
    cy.get('#identifierId')
    .type('user@gmail.com') // <<-- error here
  })
4

2 回答 2

5

This does not work due to Cypress not having fully implemented iframe support.

However, Cypress does not suggest visiting 3rd party applications within your tests. There are many reasons for this including:

  • It is incredibly time consuming and slows down your tests.
  • The 3rd party site may have changed or updated its content.
  • The 3rd party site may be having issues outside of your control.
  • The 3rd party site may detect you are testing via a script and block you.
  • The 3rd party site may be running A/B campaigns.

Cypress has outlined the downsides to visiting 3rd party sites you do not control and some workarounds in their docs. I suggest reading the full explanation here.

于 2017-12-20T19:20:11.923 回答
-3

检查 DOM 元素是否可见。identifierId 不可见

于 2017-12-15T12:25:44.520 回答