你如何检查是否有 casper (+phantom) 的重定向?试试看 :
casper.test.begin('\n********* check 301 : ***********', function(test){
casper.start('http://www.linternaute.com/ville/rennes2/ville-35238', function(response){
this.test.assertHttpStatus(301);
})
.run(function() {
this.test.comment('--- Done ---\n');
test.done();
});
});
它适用于 casper+slimer,但不适用于 casper+phantom。
curl -i http://www.linternaute.com/ville/rennes2/ville-35238
输出 :HTTP/1.1 301 Moved Permanently
输出 casper+slimer :PASS HTTP status code is: 301
输出 casper+phantom:FAIL #current: 200, #expected: 301
-> 问题?
差异更纤细/幻影->When PhantomJS receives a redirection as HTTP response, it doesn’t call the onResponseReceive with the start status,slimerJS calls it