-
-
Save bitfed/5e6e7b3a0d4ea1df441f1bbfc7a42435 to your computer and use it in GitHub Desktop.
Logging in
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
'use strict'; | |
var phantom = require("phantom"); | |
var _ph, _page, _outObj; | |
phantom.create().then(ph => { | |
_ph = ph; | |
return _ph.createPage(); | |
}).then(page => { | |
_page = page; | |
_page.on('onConsoleMessage', msg => { | |
console.log(msg); | |
}); | |
return _page.open('https://url.with.login/form'); | |
}).then(status => { | |
console.log(status); | |
_page.evaluate(function () { | |
console.log('beginning eval'); | |
document.getElementById('cbStaff').click(); | |
document.getElementById('txtLoginUsername').value = 'email@gmail.com'; | |
document.getElementById('txtLoginPassword').value = 'password'; | |
document.getElementById('btnLogin').click(); | |
//Not sure how to handle being logged in and forwarded | |
}); | |
}).then(content => { | |
_page.close(); | |
_ph.exit(); | |
}).catch(error => { | |
console.log(error); | |
_ph.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment