Events after clickMouseButton

你。 提交于 2019-12-12 05:27:32

问题


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);
    });

The code behind JE.Buttons.Scrolling() is:

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

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.


回答1:


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.

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…


来源:https://stackoverflow.com/questions/34099116/events-after-clickmousebutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!