Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Created August 1, 2012 05:20
Show Gist options
  • Save JamesMGreene/3223914 to your computer and use it in GitHub Desktop.
Save JamesMGreene/3223914 to your computer and use it in GitHub Desktop.
Response to question on PhantomJS forum: https://groups.google.com/forum/#!topic/phantomjs/DouaSrjwwCE
// Response to question on PhantomJS forum: https://groups.google.com/forum/#!topic/phantomjs/DouaSrjwwCE
function doAlpha(url) {
var page = require('webpage').create();
page.open(url, function(status) {
if (status === 'success') {
elements = page.evaluate(function() {
// ...
return result;
});
var coordinates = elements.split(',');
while (coordinates.length) {
var coordinate = coordinates.shift().split(':');
var left = parseInt(coordinate[0], 10);
var top = parseInt(coordinate[1], 10);
page.sendEvent('click', left + 1, top + 1);
}
page.release();
phantom.exit();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment