简体   繁体   English

如何在夜视仪中检查元素的文本长度是否大于0?

[英]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? 如何在夜视仪中检查元素的文本长度是否大于0?

I want to check the length of text of an element on a page to make sure it is greater than 0 using nightwatch. 我想检查页面上元素的文本长度,以确保它使用夜视仪大于0。

You can make your own custom command that uses browser.assert. 您可以创建自己的使用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();
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM