i'm trying to assert/verify multiple elements for an attribute with Nightwatch.js.
I tried to use the "elements" command by selenium but it seems to not actually return a tag.
browser.elements('css selector','icon_checkmark', function (result) {
this.verify.attributeEquals(result.value, 'aria-hidden', 'true');
})
The console outputs this error:
Testing if attribute aria-hidden of <[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]> equals "true".
Element could not be located. - expected "true" but got: null
ERROR: Unable to locate element: "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" using: css selector
It seems like it finds the right things because there should be 6 but then somehow I read out the wrong thing? Console.log of result.value[0] gives just { ELEMENT: '19' } which seems correct.
Any idea how could I make this work? I want to check if all elements with the class icon_checkmark have an attribute aria-hidden="true".
attributeEquals
locate element using css selector, while elements
returns ID
of element, so you can't locate the element that way. You can use elementIdAttribute
to get the element and verify it.
browser.elements('css selector','icon_checkmark', function (result) {
result.value.map(function (v, k) {
browser.elementIdAttribute(v.ELEMENT, 'aria-hidden', function (res) {
// true
return browser.assert.equal(res.value, 'expected value');
});
});
})