Commit 0c4095fb 0c4095fbe02780ed2f13149cad258c9154293057 by Nicolas Perriault

updated all samples to use the cli executable

1 parent 1b7e6c85
......@@ -3,7 +3,11 @@
* log every received resource.
*
*/
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var casper = new phantom.Casper({
/**
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var logo;
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var links = [
'http://google.com/',
......
phantom.injectJs("casper.js");
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var articles = [];
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var links = [];
var casper = new phantom.Casper();
......
......@@ -9,6 +9,12 @@
* borris: 2370000
* winner is "nicolas" with 69600000 results
*/
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
phantom.Casper.extend({
fetchScore: function() {
return this.evaluate(function() {
......
......@@ -4,7 +4,9 @@
#
# (all arguments will be used as the query)
#
phantom.injectJs('casper.js')
if not phantom.casperLoaded
console.log "This script is intended to work with CasperJS, using its executable."
phantom.exit 1
links = []
casper = new phantom.Casper
......
phantom.injectJs("casper.js");
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var casper = new phantom.Casper({
logLevel: "debug"
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var casper = new phantom.Casper({
verbose: true,
logLevel: 'debug'
})
});
casper.log('this is a debug message', 'debug');
casper.log('and an informative one', 'info');
casper.log('and a warning', 'warning');
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var casper = new phantom.Casper({
logLevel: "debug",
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
var links = [];
var casper = new phantom.Casper({
......
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
if (phantom.args.length === 0) {
console.log('You must provide a timeout value')
if (phantom.casperArgs.args.length === 0) {
console.log('You must provide a timeout value');
phantom.exit(1);
}
var timeout = Number(phantom.casperArgs.args[0], 10);
if (timeout < 1) {
console.log('A timeout value must be a positive integer');
phantom.exit(1);
} else {
var timeout = Number(phantom.args[0], 10);
if (timeout < 1) {
console.log('A timeout value must be a positive integer')
phantom.exit(1);
}
}
var casper = new phantom.Casper({
// verbose: true,
// logLevel: "debug",
stepTimeout: timeout,
onStepTimeout: function(self) {
self.echo(self.requestUrl + ' failed to load in less than ' + timeout + 'ms', 'ERROR');
......@@ -27,13 +29,17 @@ var links = [
'http://cdiscount.fr/'
];
casper.echo('Testing with timeout=' + timeout);
casper.start();
casper.each(links, function(self, link, i) {
self.test.comment('Adding ' + link + ' to test suite');
self.thenOpen(link, function(self) {
self.echo(self.requestUrl + ' loaded');
});
});
casper.run(function(self) {
self.test.renderResults(true);
self.exit();
......
......@@ -14,15 +14,18 @@
* Will google.com load in less than 2000ms?
* YES!
*/
phantom.injectJs('casper.js');
if (!phantom.casperLoaded) {
console.log('This script is intended to work with CasperJS, using its executable.');
phantom.exit(1);
}
if (phantom.args.length === 0) {
console.log('You must provide a timeout value')
if (phantom.casperArgs.args.length === 0) {
console.log('You must provide a timeout value');
phantom.exit(1);
} else {
var timeout = Number(phantom.args[0], 10);
var timeout = Number(phantom.casperArgs.args[0], 10);
if (timeout < 1) {
console.log('A timeout value must be a positive integer')
console.log('A timeout value must be a positive integer');
phantom.exit(1);
}
}
......