gpt4 book ai didi

javascript - NightwatchJS : How to check if attribute is not present?

转载 作者:行者123 更新时间:2023-11-29 21:16:06 27 4
gpt4 key购买 nike

我想使用 NightwatchJS 检查 disabled 属性是否出现在 button 上。

我试过这样做:

  • .assert.attributeContains('.phone-verify-btn', 'disabled', 'null')

  • .assert.attributeContains('.phone-verify-btn', 'disabled', null)

  • .assert.attributeContains('.phone-verify-btn', 'disabled', 'false')

  • .assert.attributeContains('.phone-verify-btn', 'disabled', false)

但是这些似乎并不像检查 disabled 是否设置为 true 那样工作:

  • .assert.attributeContains('.phone-verify-btn', 'disabled', 'true')

这很好用!知道这里发生了什么吗?我得到的错误是相当神秘的:

元素没有禁用属性。 - 预期为“null”但得到:null

最佳答案

在这种情况下,我认为你应该先获取属性,直到我们有更好的解决方案。这个对我有用:

 Browser.getAttribute('@element','disabled',function(result){
if(result.value === 'true'){
// element is disabled , do what you want
}
// element not disabled .
})

也许这不符合逻辑!

关于javascript - NightwatchJS : How to check if attribute is not present?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39368409/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com