【问题标题】:Events after clickMouseButtonclickMouseButton 之后的事件
【发布时间】:2023-04-10 11:41:01
【问题描述】:

在我的一项测试中,我将鼠标移动到特定位置,然后调用 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 中的定位器在首次加载时确实与页面上的内容绑定。是这样吗,我应该如何去做我需要发生的事情?我对此没有其他解释,但希望你能解释。

【问题讨论】:

    标签: javascript intern leadfoot


    【解决方案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…
    

    【讨论】:

    • 像冠军一样工作!非常感谢!
    猜你喜欢
    • 2013-09-17
    • 2013-04-30
    • 2021-10-08
    • 2016-11-17
    • 2023-03-08
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多