Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I check that the length of text of an element is greater than 0 in 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.

like image 475
Brown A Avatar asked Mar 18 '16 00:03

Brown A


1 Answers

You can make your own custom command 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();
  }
};
like image 182
the binary Avatar answered Nov 14 '22 21:11

the binary