Monday, 13 March 2017

Unhandled rejection Error - horseman

Im trying to run the example code from horsemanjs slightly modified:

var Horseman = require('node-horseman');
var horseman = new Horseman();
horseman
    .userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
    .open('http://www.google.com')
    .type('input[name="q"]', 'github')
    .click('[name="btnK"]')
    .keyboardEvent('keypress', 16777221)
    .waitForSelector('div.g')
    .plainText()
    .log()
    .close();

It did work some days ago, but suddenly decided not to. I get this when I run it:

-> Debug=horseman node test.js
   horseman using PhantomJS from phantomjs-prebuilt module +0ms
   horseman .setup() creating phantom instance 1 +3ms
   horseman phantom created +195ms
   horseman .close(). +13ms
Unhandled rejection Error
      at IncomingMessage.<anonymous(/home/halvor/BettingSource/node_modules/node-phantom-simple/node-phantom-simple.js:612:14)
      at IncomingMessage.emit (events.js:188:7)
      at endReadableNT (_stream_readable.js:974:12)
      at _combinedTickCallback (internal/process/next_tick.js:80:11)
      at process._tickCallback (internal/process/next_tick.js:104:9)

Phantomjs works from the terminal and I've tried to reinstall the node modules. I must note that have very little experience with node.

Note: To install phantomjs/horseman I did the following:

  1. Downloaded the tar.gz file from phantomjs website and extracted it, placed it in bath (/home/bin)
  2. Ran "npm install phantom" (in /home/halvor/BettingSource)
  3. Ran "npm install phantomjs"
  4. Ran "npm install node-horseman"

Both of the times I installed phantom(js) it said phantomjs not found in path and downloaded it again.



via Chip

No comments:

Post a Comment