This is a Node.js package that provides a Zombie.js shim around the PhantomJS headless
browser. The motivation behind this package is that when looking for a headless
browser solution, I really liked the API of Zombie.js as well as the full Node.js
support behind it, however it is not a full WebKit browser. PhantomJS on the other
hand is a better technology in terms of headless browser, but does not have a
native Node.js integration. The Node Phantom
package integrates the PhantomJS into the Node.js framework, but what it doesn't
do, and likely so, is provide a better API like the Zombie.js framework.

This package simply attempts to act as a drop-in replacement for Zombie.js but
using the PhantomJS headless browser.

NOTE: THIS PACKAGE IS STILL INCOMPLETE AND IS NOT A FULL DROP-IN REPLACEMENT
FOR ZOMBIE.JS

Using this library is going to be 'similar' to using Zombie.js. I couldn't make
it an exact replica of Zombie.js due to the nature of the asynchronous behavior
of interacting with any API within PhantomJS. For example, to get the text of
an element on the page looks like the following in both Zombie.js and this module.

Another big difference is that this library does not return actual DOM elements
which you can use to manipulate. It does however, return an index into a DOM
array within the PhantomJS browser which you can use to perform the same actions
as you would with Zombie.js. It is easier to think of this index as a DOM element
ID which you return back to the library to do stuff... Here is an example.

var _ = require('underscore');

var async = require('async');

var Browser = require('zombie');

var browser = new Browser({

site: 'http://localhost:8888'

});

browser.visit('/user/login', function() {

browser.query('h1.title', function(title) {

// title is actually an ID to a DOM element here, not an actual element.

// But, I can still pass it along to the browser API like I would and it

// will still work by referencing the DOM element within PhantomJS.

browser.xpath('..//label', title, function(labels) {

// labels is actually just an array of ID's here, but I can still use them

As you can tell, the promise system from Zombie.js has not been implemented,
however, you can replicate this functionality using the Async.js
library. Here is an example of using the promises from async to turn what
was once callback hell into an easy to follow series of executions.

example.js

var Browser = require('zombie-phantom');

var async = require('async');

var browser = new Browser({

site: 'http://localhost:8888'

});

// Current this library does not support promises, but you can use async.series