【发布时间】:2019-09-08 07:59:30
【问题描述】:
我正在使用cypress test来检查页面中的所有按钮是否可以点击。
我用过这行代码:
cy.get('button').click({ force: true }).should('have.attr', 'href')
并给出错误
CypressError: cy.click() 只能在单个元素上调用。您的 主题包含5个元素。如果你想传递 { multiple: true } 连续点击每个元素。
之后更改代码:
cy.get('button').click({ multiple: true }).should('have.attr', 'href')
又遇到一个错误
CypressError: Timed out retrying: cy.click() failed 因为这个 元素不可见:
...
这个元素 '' 不可见,因为它具有 CSS 属性:'display: none'
修复此问题,或使用 {force: true} 禁用错误检查。
有没有办法同时使用这两个对象来解决问题?
【问题讨论】:
标签: automation automated-tests cypress