PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selectors, JSON, Canvas, and SVG.
- Headless web testing. Lightning-fast testing without the browser is now possible! Various test frameworks such as Jasmine, Capybara, QUnit, Mocha, WebDriver, YUI Test, BusterJS, FuncUnit, Robot Framework, and many others are supported.
- Page automation. Access and manipulate web pages with the standard DOM API, or with usual libraries like jQuery.
- Screen capture. Programmatically capture web contents, including CSS, SVG and Canvas. Build server-side web graphics apps, from a screenshot service to a vector chart rasterizer.
- Network monitoring. Automate performance analysis, track page loading and export as standard HAR format.
- Multiplatform, available on major operating systems: Windows, Mac OS X, Linux, and other Unices.
- Fast and native implementation of web standards: DOM, CSS, JavaScript, Canvas, and SVG. No emulation!
- Pure headless (no X11) on Linux, ideal for continuous integration systems. Also runs on Amazon EC2, Heroku, and Iron.io.
- Easy to install: Download, unpack, and start having fun in just 5 minutes.
The PhantomJS JavaScript API can be used to open web pages, take screenshots, execute user actions, and run injected JavaScript in the page context. For example, the following code will open Wikipedia and, upon loading, will save a screenshot to a file and exit.
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://en.wikipedia.org/';
page.open(url, function (status) {
console.log('Page loaded');
page.render('wikipedia.org.png');
phantom.exit();
});
PhantomJS is created and maintained by Ariya Hidayat (Twitter: @ariyahidayat), with the help of many contributors. Follow the official Twitter stream @PhantomJS to get the frequent development updates.