Skip to content Skip to sidebar Skip to footer

Casperjs Doesn't Work As Expected On Windows Machine

I have a casperjs script which gives the desired result when I run on a linux server, but when I run the same from my laptop, it doesn't work. How should I debug? Logs of the worki

Solution 1:

Add a resource.error event handler:
casper.on("resource.error", function(resourceError){
    console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
    console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
});

It seems, this is a known PhantomJS bug (Fixed in 2.5 beta). You can download PhantomJS 2.5 beta from this page.

See also: CasperJS/PhantomJS doesn't load https pagePhantomJS failing to open HTTPS site

You need to add the following callbacks, to catch all the errors:
casper
.on("error", function(msg){ this.echo("error: " + msg, "ERROR") })
.on("page.error", function(msg, trace){ this.echo("Page Error: " + msg, "ERROR") })
.on("remote.message", function(msg){ this.echo("Info: " + msg, "INFO") });

Post a Comment for "Casperjs Doesn't Work As Expected On Windows Machine"