How to I check that the length of text of an element is greater than 0 in nightwatch?
I want to check the length of text of an element on a page to make sure it is greater than 0 using nightwatch.
How to I check that the length of text of an element is greater than 0 in nightwatch?
I want to check the length of text of an element on a page to make sure it is greater than 0 using nightwatch.
Share Improve this question edited Oct 17, 2018 at 11:41 Bárbara Peres 5951 gold badge9 silver badges26 bronze badges asked Mar 18, 2016 at 0:49 Brown ABrown A 9795 gold badges14 silver badges22 bronze badges1 Answer
Reset to default 9You can make your own custom mand that uses browser.assert.
module.exports = {
'Length of text should be greater zero': function(browser) {
browser
.url('..')
.getText('#some-selector', function(result) {
browser.assert.ok(result.value.length > 0);
})
.end();
}
};