m7v
11/19/2015 - 3:48 AM

How to check JS errors on remote sites via CasperJS.

How to check JS errors on remote sites via CasperJS.

casper.on('resource.received', function(resource) {
    var status = resource.status;
    if(status >= 400) {
        casper.log('Resource ' + resource.url + ' failed to load (' + status + ')', 'error');

        resourceErrors.push({
            url: resource.url,
            status: resource.status
        });
    }
});