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)
With Bluebird debug:
➜ BettingSource DEBUG=horseman BLUEBIRD_DEBUG=1 node test.js
horseman using PhantomJS from phantomjs-prebuilt module +0ms
horseman .setup() creating phantom instance 1 +3ms
horseman phantom created +149ms
horseman .close(). +16ms
Unhandled rejection HeadlessError: Error parsing JSON from phantom: SyntaxError: Unexpected end of JSON input
Data from phantom was:
at IncomingMessage.<anonymous> (/home/halvor/BettingSource/node_modules/node-phantom-simple/node-phantom-simple.js:612:14)
at emitNone (events.js:91:20)
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)
From previous event:
at prepare (/home/halvor/BettingSource/node_modules/node-horseman/lib/index.js:54:9)
at new Horseman (/home/halvor/BettingSource/node_modules/node-horseman/lib/index.js:155:15)
at Object.<anonymous> (/home/halvor/BettingSource/test.js:2:16)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:425:7)
at startup (bootstrap_node.js:146:9)
at bootstrap_node.js:540:3
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:
- Downloaded the tar.gz file from phantomjs website and extracted it, placed it in bath /home/bin
- Ran npm install phantom in /home/halvor/BettingSource
- Ran npm install phantomjs
- Ran npm install node-horseman
Both of the times I installed phantomjs it said phantomjs not found in path and downloaded it again.