Created
April 29, 2016 23:09
-
-
Save ahgood/ba3d163d160a747c664f4b939fd55c89 to your computer and use it in GitHub Desktop.
PhantomJS sample script
This file contains hidden or 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
var page = require('webpage').create(); | |
page.onConsoleMessage = function(msg) { | |
console.log(msg); | |
}; | |
page.open("http://www.somewebsite.com", function(status) { | |
if ( status === "success" ) { | |
page.evaluate(function() { | |
document.querySelector("input[name='MAIL_ADDRESS']").value = "[email protected]"; | |
document.querySelector("input[name='PASSWORD']").value = "mypassword"; | |
document.getElementsByName("LOGIN_FORM_SUBMIT")[0].click(); | |
console.log("Login submitted!"); | |
}); | |
window.setTimeout(function () { | |
page.render('screenshot.png'); | |
var ua = page.evaluate(function () { | |
return document.getElementById('AnElementIdOnMyWebsite').innerText; | |
}); | |
console.log(ua); | |
phantom.exit(); | |
}, 5000); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment