NightmareJS ничего не показывает - PullRequest
0 голосов
/ 01 июля 2019

Я пытаюсь выполнить пример из https://github.com/segmentio/nightmare, но он ничего не возвращает


package.json

{
  "name": "new_nightmare",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "nightmare": "^3.0.2"
  }
}

index.js

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })

console.log('before')
nightmare
    .goto('https://duckduckgo.com')
    .type('#search_form_input_homepage', 'github nightmare')
    .click('#search_button_homepage')
    .wait('#r1-0 a.result__a')
    .evaluate(() => document.querySelector('#r1-0 a.result__a').href)
    .end()
    .then(function (result) {
        console.log('Result ->', result)
    })
    .catch(error => {
        console.error('Search failed:', error)
    })
console.log('after')

выход

enter image description here

...