Skip to content

Instantly share code, notes, and snippets.

@qcom
Created June 5, 2013 21:30
Show Gist options
  • Save qcom/5717476 to your computer and use it in GitHub Desktop.
Save qcom/5717476 to your computer and use it in GitHub Desktop.
var casper = require('casper').create({
clientScripts: ['includes/jquery-2.0.1.min.js'],
logLevel: 'debug',
verbose: true
});
var noop = function() {};
var index = 'http://www.orsnasco.com/storefrontB2BWEB/';
var manIndex = 'http://www.orsnasco.com/storefrontB2BWEB/customauth/manIndex.jsp';
function wrap(fn) {
var args = Array.prototype.slice.call(arguments, 1);
return function() {
fn.apply(this, args);
};
}
function capture() {
this.capture('screen.png');
}
function login(username, password) {
if (this.getCurrentUrl() !== index)
this.thenOpen(manIndex, username, password);
this.fill('form[action="/storefrontB2BWEB/login.do?setup_principal=true"]', {
usr_name: username,
usr_password: password
});
this.click('input[src="/storefrontB2BWEB/custom/images/home-greenarrow.gif"]');
}
function getManufacturers() {
}
function main() {
var username = 'foo';
var password = 'bar';
this.thenOpen('http://www.google.com/', noop);
this.then(wrap(login, username, password));
this.then(capture);
}
casper.start(index, main);
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment