Skip to content

Instantly share code, notes, and snippets.

@npow
Created August 13, 2012 03:23
Show Gist options
  • Save npow/3336688 to your computer and use it in GitHub Desktop.
Save npow/3336688 to your computer and use it in GitHub Desktop.
Creating mouse events
phantom.casperPath = '/Users/npow/Downloads/dev/casperjs';
phantom.injectJs(phantom.casperPath + '/bin/bootstrap.js');
var casper = require('casper').create();
casper.on('remote.message', function(message) { console.log(message); });
casper.start("http://localhost:8888/charts/TrendLineTest.htm", function () {
// setup here
});
casper.then(function () {
this.mouse.click(150, 150);
this.evaluate(function () {
var e = document.createEvent('MouseEvents');
e.initMouseEvent('mousemove', true, true, window, 1, 400, 400, 400, 400);
var canvas = document.getElementById('trendLine');
canvas.dispatchEvent(e);
});
casper.capture('ss1.png');
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment