CasperJS script never exits

后端 未结 2 1250
你的背包
你的背包 2020-12-21 06:55

My CasperJS script never stops executing.

var casper = require(\'casper\').create();

casper.userAgent(\'Mozilla/5.0 (         


        
相关标签:
2条回答
  • 2020-12-21 07:14

    It only looks as if CasperJS never exits. This is only an issue on windows. You probably see something like this:

    C:\> casperjs script.js
    
    C:\> Some script output
    More script output
    _
    

    It has something to do with how CasperJS is installed and invoked. This happens usually when you have something like cygwin installed and then you install CasperJS through NPM. NPM will detect that you have cygwin and create a special batch file to start CasperJS with. There is somewhere a bug how that whole situation is handled, but it doesn't affect the functionality of CasperJS.

    If you press Enter, you will see the prompt again:

    C:\> casperjs script.js
    
    C:\> Some script output
    More script output
    
    C:\> _
    

    If you would use CasperJS from the master branch on GitHub, you would get a proper exe file which executes without those issues. See Installing from git. This has the advantage that you now can use PhantomJS 2, because it is not possible with the current release of version 1.1-beta3.

    0 讨论(0)
  • 2020-12-21 07:15

    Try adding exit on you run method.

    casper.run(function() {
      this.exit();
    });
    
    0 讨论(0)
提交回复
热议问题