0

在我的一项测试中,我将鼠标移动到特定位置,然后clickMouseButton()被调用。此操作是更改显示的数据(对数据进行分页)。但是,单击后,当我尝试获取表格列中的文本以验证数据是否更改时,数据更改回最初显示的内容我的测试失败了。我的测试代码是:

return Remote
    .moveMouseTo(JE.Buttons.Scrolling(), 5, 100)
    .clickMouseButton()
    .end(Infinity)
    .sleep(500)
    .findByXpath('//*[@id="vwNJEAll_grid_header_tbody"]/tr[2]/td[2]/div')
    .getVisibleText()
    .then(function (result) {
        expect(result).not.to.equal(firstSeenJENumber);
    });

后面的代码JE.Buttons.Scrolling()是:

return Remote
    .setFindTimeout(5000)
    .findByXpath('//*[@id="vwNJEAll_grid_table_container"]/div[2]/div');

在我看来,Leadfoot 中的定位器在首次加载时确实与页面上的内容绑定。是这样吗,我应该如何去做我需要发生的事情?我对此没有其他解释,但希望你能做到。

4

1 回答 1

1

moveMouseTo不接受 Promise 作为其第一个参数,因此该moveMouseTo调用是错误的并且不会执行您想要的操作。您的示例代码中的JE.Buttons.Scrolling()调用也会立即发生(在命令链构建期间),它不会仅moveMouseTo在实际执行一次时发生。

要通过抽象函数检索和使用元素,请将函数传递给then然后使用该元素:

return Remote
  .then(JE.Buttons.Scrolling)
  .then(function (element) {
    return Remote.moveMouseTo(element, 5, 100);
  })
  // …remainder of test…
于 2015-12-05T06:17:57.623 回答