Node.js 如何使用噩梦ejs正确停止phantomjs实例
我想用梦魇来截图我的网络应用。当运行代码时没有错误并且出口是干净的时,就不会留下任何phantomjs实例Node.js 如何使用噩梦ejs正确停止phantomjs实例,node.js,phantomjs,nightmare,Node.js,Phantomjs,Nightmare,我想用梦魇来截图我的网络应用。当运行代码时没有错误并且出口是干净的时,就不会留下任何phantomjs实例 var Nightmare = require('nightmare'); var Screenshot = require('nightmare-screenshot'); var nightmare = new Nightmare(); var url = process.argv[2]; var url = process.argv[3]; nightmare .goto(u
var Nightmare = require('nightmare');
var Screenshot = require('nightmare-screenshot');
var nightmare = new Nightmare();
var url = process.argv[2];
var url = process.argv[3];
nightmare
.goto(url)
.wait('#selector')
.use(Screenshot.screenshotSelector(path, '#selector'))
.run(function (err, nightmare) {
if (err)
console.log('Error');
else
console.log('Done.');
nightmare.teardownInstance();
nightmare.end();
});
但是,当出现一些错误(如web未运行)时,选择器不存在。PhantomJ的实例仍然未使用
$ ps -ax | grep phantom
6065 ttys004 0:00.00 grep phantom
6050 ttys005 0:02.87 phantomjs --load-images=true --ignore-ssl-errors=true --ssl-protocol=any --web-security=true /.../node_modules/phantom/shim.js 13201 127.0.0.1
即使有任何错误,我如何才能正确地退出它的实例?目前,.wait(elem)
继续循环,每250毫秒检查一次元素是否存在。您可以将此情况报告给开发人员,以添加传递附加参数,从而在特定超时后停止检查,以便正常退出
或者,您可以通过手动检查元素是否存在特定超时,然后退出流程来解决此问题
您可以使用
wait(fn)
执行检查。是的,我也认为这可能是问题所在。顺便问一下,你是如何发现每250毫秒进行一次it检查的?