Last active
December 15, 2015 11:28
-
-
Save mickaelandrieu/5252776 to your computer and use it in GitHub Desktop.
Sample of command that does'nt work (casperjs includes)
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
casperjs --includes=utilities/login.js [email protected] password domain test bank.js | |
Unable to open file: [email protected] |
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 casper = require('casper').create({ | |
/* more traces with this 2 following options */ | |
verbose: true, | |
//logLevel: "info", | |
httpStatusHandlers: { | |
500: function(self, resource) { | |
this.warn("Resource at " + resource.url + " server error (500)"); | |
}, | |
404: function(self, resource) { | |
this.warn("Resource at " + resource.url + " is unreachable (404)"); | |
}, | |
301: function(self, resource) { | |
this.warn("Resource at " + resource.url + " is moved permanently (301)"); | |
}, | |
302: function(self, resource) { | |
this.warn("Resource at " + resource.url + " is moved temporarily (302)"); | |
} | |
}, | |
}); | |
/* get args */ | |
var email = casper.cli.get(0); | |
var password = casper.cli.get(1); | |
var domain = casper.cli.get(2); | |
// Go to the AM 2 Login Page | |
casper.test.comment('Go to Login Page'); | |
casper.start(domain, function() { | |
this.test.pass('Login Page is loaded'); | |
this.capture(folder+'pageLoad.png'); | |
}); | |
// Test a Bad submit | |
casper.thenOpen(domain,function() { | |
this.test.info('Current location is ' + this.getCurrentUrl()); | |
this.fill('#showcaseLoginForm', { | |
'_username': email, | |
'_password': password | |
}, true); | |
}); |
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
// Test a Bad submit | |
casper.then(function() { | |
this.test.info('Current location is ' + this.getCurrentUrl()); | |
}); | |
casper.run(function() { | |
this.test.done(); | |
}); |
Works ! Thanks, I update my sample (maybe I can do a PR for the documentation ?)
It's theoretically documented already, but feel free to send a PR with enhancements if you think the docs need them :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try it that way:
and:
Also, be sure to use the
casperjs test
subcommand, and don't create a casper instance within that environment.