【问题标题】:Not able to use attribute selector in cypress无法在柏树中使用属性选择器
【发布时间】:2020-07-05 00:45:54
【问题描述】:

我的 HTML 片段是:

<label class="email">
  Email
  <input data-test="email" type="text" v-model="curMember.email_address">
</label>

然后在我的 cypress 测试中,以下 'GET' 不起作用(使用属性选择器):

cy.get('[data-test="email"]').should('have.value', 'a@test.com')

上述尝试查找元素时超时,但以下确实有效(使用类选择器)

cy.get('.email>input').should('have.value', 'a@test.com')

谁能告诉我我的问题是什么?

【问题讨论】:

标签: vue.js cypress


【解决方案1】:

我不确定 cypress 是否能够从 NON-class 中获取价值 但是看看这个https://docs.cypress.io/api/commands/get.html#Selector

对于第一个例子,你只能检查长度

cy.get('[data-test="email"]').should('have.length', '10')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-09
    • 1970-01-01
    • 2022-11-12
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    相关资源
    最近更新 更多