如何在nightwatch.js中使用页面对象上的元素列表?

时间:2017-04-05 15:35:16

标签: javascript selenium-webdriver nightwatch.js

我有一个页面对象

export default {
  url: function () {

    return `${this.api.launch_url}/custompage`;

  },
  commands: [customPageCommands],
  sections: {
    table: {
      selector: '.table tbody',
      elements: {
        tableRows: {
          selector: 'td'
        }
      }
    }
  }
};

tableRows应该返回一个元素列表。在我的测试中,我想检查表中行的数量。有人有解决方案吗?

1 个答案:

答案 0 :(得分:1)

有一个名为element()的函数,你可以在你的页面对象中尝试这个(在customPageCommands中包含它):

{{1}}