nightmare.js不返回任何输出
我试着用下面的命令运行我的test.js文件:
DEBUG=nightmare node --harmony test.js
并输出:
nightmare queueing action "goto" for http://google.com +0ms nightmare queueing action "wait" +2ms nightmare queueing action "screenshot" +0ms
test.js:
var Nightmare = require('nightmare'); var google = new Nightmare() .goto('http://google.com') .wait() .screenshot("./screen.png") .run(function(err, nightmare) { if (err) return console.log(err); console.log('Done!'); });
没有截图和链接访问。 有什么想法吗?
注意:我正在使用Linux Guest虚拟机。
试试:
var google = new Nightmare({ show: true })
您将能够看到链接是否打开。
对于debugging尝试使用下面的代替:
DEBUG=nightmare:actions node --harmony test.js
这会告诉你,代码抛出错误,就像你的情况:
nightmare:actions Not enough arguments for .wait()
.wait()需要一个时间间隔或一个函数返回true或一个DOM元素。
尝试像这样:
.wait(2000) // For 2 sec wait .wait("input[type='text'][title='Search']") // To wait till the search box is loaded .wait( () => { // Check Something return true })
请检查上述帮助是否解决您的问题。