Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

casperjs error: casper has no method start when running from node.js

Running the simplest of casperjs examples gives me an error:

casper.start('http://casperjs.org/', function() {
       ^
TypeError: Object function (req, res) {
    var raw = new Model(data || (allowBody ? req.body : {}));
    raw.save(cb || function (err, obj) {
      if (err) return res.jsonp(500, err);
      res.jsonp(obj);
    });
  } has no method 'start'
    at Object.<anonymous> (/Users/path/to/main.js:16:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

The code I am running is:

var utils = require('utils');
var casper = require('casper').create();

casper.start('http://casperjs.org/', function() {
    this.echo(this.getTitle());
});

casper.thenOpen('http://phantomjs.org', function() {
    this.echo(this.getTitle());
});

casper.run();

Node:js version - v0.10.22 CasperJS version 1.1.0-beta3 at /usr/local/lib/node_modules/casperjs, using phantomjs version 1.9.2 Host OS is OSX 10.8.5

like image 370
codecowboy Avatar asked Nov 01 '22 08:11

codecowboy


1 Answers

From the CasperJS FAQ:

Is CasperJS a node.js library? No. CasperJS is written on top of PhantomJS, which is a node-independent Qt/WebKit based library. If you try to run your CasperJS script with node, it just won’t work out of the box.

Hint: If you want to drive CasperJS from node, try SpookyJS.

Source

like image 116
hexid Avatar answered Nov 13 '22 01:11

hexid