8

I'm migrating a script from PhantomJS to CasperJS, and am wondering if Casper provides any references to the Phantom objects that it is using behind the scenes.

Phantom provides some functionality that Casper doesn't (injectJs, for example).

For completeness' sake, here are all of Phantom's objects:

By looking at the casper object's properties, I did find a reference to the webpage object (casper.page), so my particular use case is handled. I figured I would post this question anyway in case other people need access to system, fs, webserver, or child_process.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
mwcz
  • 8,949
  • 10
  • 42
  • 63

2 Answers2

4

I know that with the system and fs modules, you are able to use the same APIs as you would with CasperJS as you would with PhantomJS. This is most likely true for webserver and child_process as well. What I mean by this, is that you can continue to require these modules as you would with PhantomJS, ex:

var fs = require('fs');
var sys = require('system');

As for webpage, you can take a look at my answer here as to how to access the page object that CasperJS uses to run on top of PhantomJS.

Community
  • 1
  • 1
hexid
  • 3,811
  • 1
  • 30
  • 40
  • Good stuff, hope this helps someone! – mwcz May 23 '13 at 18:00
  • 1
    "This is most likely true for `webserver` and `child_process`" - This is true for `child_process` since implementation of [issue#515 "add support for phantomjs child_process"](https://github.com/n1k0/casperjs/issues/515) – Alberto Jul 02 '13 at 12:39
1

Here an example about how you can use the webserver module in CasperJS

CasperJS passing data back to PHP

Community
  • 1
  • 1
Hemerson Varela
  • 24,034
  • 16
  • 68
  • 69