【问题标题】:Conditional test in CypressCypress 中的条件测试
【发布时间】:2019-12-27 00:52:35
【问题描述】:

是否可以检查按钮是否被禁用而不使其成为通过或失败的断言?我想做类似的事情:

if(button is disabled) { // Run some tests } else { // Run some different tests }

我知道有关于条件测试的文档,但我没有找到解决问题的方法。

【问题讨论】:

标签: cypress


【解决方案1】:

您可以使用Jquery 获取按钮的状态并分配给一个变量并检查它是否为true

var btnStatus = Cypress.$("#SomeIdOfButton").is(":disabled");

    if(btnStatus == true){
      // do some test here..
      })
    } else{
      // some other tests..
    }

【讨论】:

    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 2022-06-29
    相关资源
    最近更新 更多