This repository is the sample code that goes along with the book The PhantomJS Cookbook. The book is a deep-dive into PhantomJS, its core APIs, and the eco-system of testing tools that have sprung up around it.
The chapters break down as follows:
- Getting Started with PhantomJS
- The PhantomJS Core Modules
- Working with
webpage
Objects - Unit Testing with PhantomJS
- Functional and End-to-End Testing with PhantomJS
- Network Monitoring and Performance Analysis
- Generating Images and Documents with PhantomJS
- Continuous Integration with PhantomJS
Here is what you'll need to run the recipes:
- PhantomJS - (version 1.9 or greater)
"the headless WebKit"; you will need this for every recipe.
- You'll also want to download the PhantomJS source code: github.com/ariya/phantomjs
- Node.js - (version 0.10.2 or greater) to run
the
phantomjs-sandbox
demo app that most of the recipes reference. - Java - (Java SE Runtime Environment 1.7.0_45 or greater) for a couple of the recipes (especially those involving Selenium); and on that note:
- Ruby - (version 1.9.3 or greater) for the recipes that involve Capybara and Poltergeist.
- Python - (version 2.6 or greater) for the recipes that involve CasperJS.
If you are following along from the book, then you may also want to pick up and install the following as well:
- WebStorm version 7.0.3 or greater;
- Jenkins CI version 1.552 or greater; and/or
Once you have cloned this repository and installed the above software, the only other things you might need to do:
- Expose
PHANTOMJS_SOURCE
as a variable in your shell. Remember the path where you cloned the PhantomJS source code? Export that to your shell asPHANTOMJS_SOURCE
. - Install the Node.js modules for the demo app.
cd
into this repo'sphantomjs-sandbox
directory and install the Node.js dependencies withnpm install
- Get YSlow as a submodule. If you're unfamiliar with this process,
cd
into the project's directory and enter:git submodule init && git submodule update
- ...and you're done.
Let's do this informally, so it's easier for everyone:
- Everything in here that I wrote (short version: the recipes) is under the MIT license.
- I tapped into the wonderful open source community and used a bunch of awesome
tools for a bunch of these recipes; in those cases (short version: most of the
stuff in the
lib
directory) I tried to include their existing licenses because I recognize those items as their intellectual property and want to respect that and properly credit them. - If you believe that I'm including something here in violation of its license agreement, please contact me and give me the chance to make it right.