的特性“焦点”我不能做恶梦JS工作:噩梦JS不能看空
我的代码
var Nightmare = require('nightmare'),
nightmare = Nightmare({
show: true
});
console.log('fer');
nightmare
.goto('http://www.google.com')
.type('input[title="Search"]', 'github nightmare')
.click('name[btnK]')
.wait('#main')
.evaluate(function() {
console.log('xxxxxx');
var x = document.querySelector('.srg .g');
var item = x.querySelector("h3").textContent;
console.log(item);
})
.end() // end the Nightmare instance along with the Electron instance it wraps
.then(function(result) {
console.log(result);
});
错误
set DEBUG=nightmare & node src\crawler\google-spider.js
nightmare queuing process start +0ms
fer
nightmare queueing action "goto" for http://www.google.com +10ms
nightmare queueing action "type" +23ms
nightmare queueing action "click" +0ms
nightmare queueing action "wait" +1ms
nightmare queueing action "evaluate" +0ms
nightmare running +1ms
nightmare electron child process exited with code 0: success! +5s
(node:7912) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Cannot read property 'focus' of null
有没有一种方式来展现,其中它失败了,或者什么是属性null
噩梦电子子进程退出代码0:成功! + 5S (节点:7912)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):无法读取空的特性 '焦点'