Cypress Error: [vee-validate] Validating a non-existent field: "#8". Use "attach()" first

Cypress Error: [vee-validate] Validating a non-existent field: "#8". Use "attach()" first

我有简单的测试。它所做的只是在输入字段中提供数据并发送它们:

  it('Try to change email', () => {

    cy.login({email: Cypress.env('basicemail'), password: Cypress.env('changepassword')})
    cy.wait(2500)
    cy.get('nav > .account-info > div > img').click()
    cy.get('aside > ul > :nth-child(5) > a').click()
    cy.wait(2500)

    cy.get('a').contains('Change email').click()

    cy.get('input[name="newEmail"]').clear().type(Cypress.env('changeemail'))
    cy.get('input[name="newEmailConfirm"]').clear().type(Cypress.env('changeemail'))
    cy.get('input[name="changeEmailPassword"]').clear().type(Cypress.env('changepassword'))

    cy.get('a').contains('Confirm').click()
    cy.get(':nth-child(5) > .settings-modal-wrapper > .button').click()

    // HERE IS ERROR
    cy.get('.modal-description').contains(`Email with confirmation link has been sent to ${Cypress.env('changeemail')}. Please follow instruction from the email.`)

    cy.get('.modal-header > img').click()
    cy.get('aside > ul > :nth-child(7) > a').click()
  })

点击按钮后,出现 3 个错误:

Error: [vee-validate] Validating a non-existent field: "#8". Use "attach()" first.

Error: [vee-validate] Validating a non-existent field: "#9". Use "attach()" first.

Error: [vee-validate] Validating a non-existent field: "#10". Use "attach()" first.

实际上,我不知道它是什么意思,我试图找出它,但没有相关信息。

这是它在控制台中的样子:

我已经解决了这个问题。其实这甚至不是关于前面,而是关于我的 API.

问题是当访问其他页面时,cypress 会从 localStorage 中删除所有内容,因此我必须执行一些操作以将其保存在 localStorage - 再登录一次。

所以,请注意这一点,问题可能出在 API,而不是前面。