问题
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