Created
August 1, 2012 05:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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