CasperJS:如何退出脚本执行? [英] CasperJS: how to exit script execution?

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

问题描述

昨天我用CasperJS编写了我的第一个测试,我发现它很棒.问题是我找不到退出脚本执行的方法(即:casperjs不存在,所以我可以重新访问控制台).通过添加像这样的最终测试,我找到了解决方法

Yesterday I've written my first tests with CasperJS and I find it amazing. The problem is that I couldn't find a way to exit the script execution (ie: casperjs doesn't exist so I can get back access to my console). I've found an workaround by adding a final test like so

casper.test.begin('Exit', function suite(test) {
    casper.exit();
});

关于这项技术,我有2个问题

Regarding this technique I have 2 questions

  1. 有更好的方法吗?
  2. 这将如何影响将结果输出到xunit文件?

推荐答案

casper.then(function() {
    this.exit();
});

是否要在脚本运行时退出脚本(由于错误)?如果不是,则无需像这样显式退出它.定义所有测试后,只需调用casper.run(),一旦所有测试运行完毕(无论结果如何),该脚本就会停止运行,并且您将重新获得对终端的控制权.

Do you want to exit the script while it's running (due to an error)? If not, then you don't need to explicitly exit it like that. Just call casper.run() after defining all your tests, and once all the tests have run (regardless of their result), the script will stop running and you'll regain control over your terminal.

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

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