CasperJS script never exits

随声附和 提交于 2019-11-29 15:24:06

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.

Try adding exit on you run method.

casper.run(function() {
  this.exit();
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!