I want to check if a disabled
attribute is not present on a button
using NightwatchJS.
I tried doing these:
.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)
But these don't seem to work like they do to check if disabled
is set to true
like so:
.assert.attributeContains('.phone-verify-btn', 'disabled', 'true')
This works just fine! Any idea what's happening here? The error I get is rather cryptic:
Element does not have a disabled attribute. - expected "null" but got: null
I want to check if a disabled
attribute is not present on a button
using NightwatchJS.
I tried doing these:
.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)
But these don't seem to work like they do to check if disabled
is set to true
like so:
.assert.attributeContains('.phone-verify-btn', 'disabled', 'true')
This works just fine! Any idea what's happening here? The error I get is rather cryptic:
Element does not have a disabled attribute. - expected "null" but got: null
-
I have the exact same problem. What I'm currently doing is
.assert.elementNotPresent('.phone-verify-btn[disabled]')
, but I also would like a cleaner solution. – Adam Zerner Commented Aug 6, 2018 at 0:14
2 Answers
Reset to default 2In this case,I think you should get attribute first until we have better solution. This one works for me :
Browser.getAttribute('@element','disabled',function(result){
if(result.value === 'true'){
// element is disabled , do what you want
}
// element not disabled .
})
Perhaps it is not really logical !
Change attributeContains to attributeEquals
.assert.attributeEquals('.phone-verify-btn', 'disabled', null)