CasperJS: Simulate swipe-event

丶灬走出姿态 提交于 2020-01-06 21:51:06

问题


I tried to build a few casperjs tests. Went well so far but at one thing I failed:

Building a test for a swipe-event.

I need something like this:

casper.mouse.down("#myelement"); // press and hold mousebutton
casper.mouse.move_x(200); // Move mouse 200 to the right
casper.mouse.up(); // Release mousebutton

But there is no function like move_x in the casper-docs.

Does anyone have an idea?


回答1:


You can easily write your own move_x method by getting the coordinates of the selector and using these as modified inputs to mouse.move(x + selector.x, selector.y).

Some people still believe this does not work. Try the following snippet:

casper.then(function() {
    this.mouse.down('div.some_selector');
    this.mouse.move(200, 100);
});

casper.then(function() {
    this.mouse.up(200, 100);
});


来源:https://stackoverflow.com/questions/25844113/casperjs-simulate-swipe-event

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