steptimeout.js
926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var failed = [];
var casper = require('casper').create({
onStepTimeout: function() {
failed.push(this.requestUrl);
}
});
var links = [
'http://google.com/',
'http://akei.com/',
'http://lemonde.fr/',
'http://liberation.fr/',
'http://cdiscount.fr/'
];
var timeout = ~~casper.cli.get(0);
if (timeout < 1) {
timeout = 1000;
}
casper.options.stepTimeout = timeout;
casper.echo("Testing with timeout=" + casper.options.stepTimeout + "ms.");
casper.start();
casper.each(links, function(self, link) {
self.test.comment('Adding ' + link + ' to test suite');
self.thenOpen(link, function(self) {
var testStatus = self.test.pass;
if (failed.indexOf(self.requestUrl) > -1) {
self.test.fail(self.requestUrl);
} else {
self.test.pass(self.requestUrl);
}
});
});
casper.run(function() {
this.test.renderResults(true);
});