Ok, for more information see Redirects not followed #442, if you still want to test 301, here a solution :
casper.on('resource.received', function(resource) {
if(resource.url === 'http://www.linternaute.com/ville/rennes2/ville-35238'){
this.test.assertEquals(301, resource.status);
};
});
But I finally chose to test redirection in this manner (easier) :
casper.test.begin('\n********* check 301 : ***********', 1, function(test){
casper.start('http://www.linternaute.com/ville/rennes2/ville-35238', function() {
this.test.assertEquals(this.getCurrentUrl(), 'http://www.linternaute.com/ville/rennes/ville-35238');
})
.run(function() {
this.test.comment('--- Done ---\n');
test.done();
});
});
I just check the current URL correspond to my redirection... An object with properties 'openUrl' and 'urlRedirected' and it's okay -in a loop-...