CasperJS脚本永不退出 [英] CasperJS script never exits

查看:168
本文介绍了CasperJS脚本永不退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的CasperJS指令码永不停止执行。

My CasperJS script never stops executing.

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

casper.userAgent('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36');

casper.start('https://www.google.co.in/',function(){    
  casper.wait(3000,function(){
    this.echo(this.getTitle());
  });
});
casper.run();


推荐答案

它看起来好像CasperJS从不退出。这只是在Windows上的问题。您可能会看到这样的:

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
_

如何安装和调用CasperJS。这通常发生在你安装了cygwin,然后通过NPM安装CasperJS。 NPM会检测到你有cygwin并创建一个特殊的批处理文件来启动CasperJS。

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.

如果你按Enter键,你会再次看到提示:

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

C:\> casperjs script.js

C:\> Some script output
More script output

C:\> _

如果你使用CasperJS从GitHub的主分支,你会得到一个合适的exe文件没有这些问题。请参见从git安装。这有一个优点,你现在可以使用PhantomJS 2,因为它是不可能的版本1.1-beta3的当前版本。

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.

这篇关于CasperJS脚本永不退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆