Commit e429daff e429daff0eb9f99544e998cc329e03bd84bb31dd by Nicolas Perriault

closes #24 - added custom logging example

1 parent f7787f50
phantom.injectJs('casper.js');
var casper = new phantom.Casper({
onResourceReceived: function(self, resource) {
var infos = [
resource.url,
resource.status,
resource.statusText,
resource.redirectURL,
resource.bodySize
];
resource.headers.forEach(function(header) {
infos.push('[' + [header.name, header.value].join(', ') + ']');
});
self.log(infos.join(', '), 'verbose');
},
verbose: true,
logLevel: 'verbose'
});
casper.logLevels = ['verbose'].concat(casper.logLevels);
casper.start('http://www.google.com/').run(function(self) {
self.exit();
});
......@@ -6,8 +6,6 @@ var links = [
'http://bing.com/'
];
var casper = new phantom.Casper();
var i = 0;
var titles = [];
casper.start();
......
......@@ -6,7 +6,7 @@ var casper = new phantom.Casper();
function getLinks() {
var links = document.querySelectorAll('h3.r a');
return Array.prototype.map.call(links, function(e) {
return e.getAttribute('href')
return e.getAttribute('href');
});
}
......
......@@ -47,7 +47,7 @@ casper.start('tests/site/index.html', function(self) {
self.click('a[href="test.html"]');
});
casper.test.assert(casper.steps.length === 1, 'Casper.start() can add a new navigation step');
casper.test.assertEquals(casper.steps.length, 2, 'Casper.start() can add a new navigation step');
// Casper.viewport()
casper.test.comment('viewport');
......@@ -63,7 +63,7 @@ casper.then(function(self) {
self.click('a[href="form.html"]');
});
casper.test.assert(casper.steps.length === 2, 'Casper.then() adds a new navigation step');
casper.test.assert(casper.steps.length === 3, 'Casper.then() adds a new navigation step');
// Casper#capture()
casper.test.comment('capturing');
......