Я не могу заставить кошмар 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: успех! +5 с (узел: 7912) UnhandledPromiseRejectionWarning: отклонение необработанного обещания (идентификатор отклонения: 1): невозможно прочитать свойство «фокус» null