Skip to content

Instantly share code, notes, and snippets.

@padcom
Created December 6, 2011 11:16
Show Gist options
  • Save padcom/1437829 to your computer and use it in GitHub Desktop.
Save padcom/1437829 to your computer and use it in GitHub Desktop.
PhantomJS example
// ----------------------------------------------------------------------------
// Page object setup
// ----------------------------------------------------------------------------
var page = new WebPage();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open(encodeURI("http://jquery.com/"), function (status) {
page.evaluate(test);
phantom.exit();
});
// ----------------------------------------------------------------------------
// Test section
// ----------------------------------------------------------------------------
function test() {
console.log($("div").length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment