clickMouseButton之后的事件 [英] Events after clickMouseButton

查看:99
本文介绍了clickMouseButton之后的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In one of my tests I have the mouse moved to a specific location and then clickMouseButton() is called. This action is to change the data that is displayed (paging the data.) However, after the click, when I try to get the text in a column of the table to verify that the data changed the data changes back to what was originally displayed and my test fails. My test code is:

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中的定位器在第一次加载时绑定到页面上的内容.是这种情况,我该如何去做我需要做的事情?我对此没有其他解释,但希望您能这样做.

It really seems to me like the locator in Leadfoot is binding to what is on the page when it first loads. Is this the case, and how should I go about getting what I need to happen? I have no other explanation for this, but hopefully you do.

推荐答案

moveMouseTo不接受Promise作为其第一个参数,因此moveMouseTo调用是错误的,不会做您想要的事情.示例代码中的JE.Buttons.Scrolling()调用也会立即发生(在命令链构建过程中),只有真正执行moveMouseTo时才会发生.

moveMouseTo doesn’t accept a Promise as its first argument, so that moveMouseTo call is wrong and won’t do what you want. The JE.Buttons.Scrolling() call in your example code also occurs immediately (during command chain construction), it doesn’t occur only once moveMouseTo is actually performed.

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

To retrieve and use an element with your abstraction function, pass the function to then and then use the element:

return Remote
  .then(JE.Buttons.Scrolling)
  .then(function (element) {
    return Remote.moveMouseTo(element, 5, 100);
  })
  // …remainder of test…

这篇关于clickMouseButton之后的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆