casperjs doesn't work as expected on windows machine

后端 未结 1 1103
礼貌的吻别
礼貌的吻别 2021-01-11 11:25

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? L

相关标签:
1条回答
  • 2021-01-11 11:55

    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 page
    PhantomJS 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") });
    
    0 讨论(0)
提交回复
热议问题