Skip to content

Instantly share code, notes, and snippets.

@adnasa
Created November 6, 2014 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adnasa/a97ed2376c11cb1a51c0 to your computer and use it in GitHub Desktop.
Save adnasa/a97ed2376c11cb1a51c0 to your computer and use it in GitHub Desktop.
Login into a system
var casper = require('casper').create();
var utils = require('utils');
var URL_LOGIN = "";
var URL_AUTH = "";
var AUTH_TOKEN = null;
var AUTH_EMAIL = null;
var AUTH_PASS = null;
casper.start(URL_LOGIN, function() {
AUTH_TOKEN = this.getElementInfo('input[name="token"]').attributes.value;
this.thenOpen(URL_AUTH, {
method: 'post',
data: {
token: AUTH_TOKEN,
email: AUTH_EMAIL,
password: AUTH_PASS
},
headers: {
'Accept': 'application/json'
}
}, function(response) {
utils.dump(response);
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment