【问题标题】:How to use Cypress to assert that a HTML element has a height or width greater than a specified amount?如何使用 Cypress 断言 HTML 元素的高度或宽度大于指定量?
【发布时间】:2019-10-27 02:01:19
【问题描述】:

Github thread 重点介绍了如何使用 Cypress 断言元素具有指定高度。

cy.get(mainMenu).should('have.css', 'height', '55px')

如何使用 Cypress 断言元素大于指定高度?

例如,我想断言某个 HTML 元素的高度总是大于 100px。

【问题讨论】:

    标签: javascript testing cypress


    【解决方案1】:
    cy.get(mainMenu).invoke('height').should('gte', 55)
    

    invoke() - 在 height 元素上调用 jquery 函数。

    gte(又名。最少) - 断言目标等于或大于给定值

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-22
      相关资源
      最近更新 更多