User:Sjha3/PhantomJS

PhantomJS is a scripted, headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment. PhantomJS is based on Webkit making it a similar browsing environment to Safari and Google Chrome (before Chrome's fork of webkit evolved into Blink). It is open-source software released under the BSD License.

History
PhantomJS was released January 23, 2011 by Ariya Hidayat after several years in development.

The first commit to the public project was in 2011. The project has maintained a steady level of weekly contributions from December 26, 2010 to present. As of October 4 2015, the project’s open source code repository is watched by 899 people and contribution is done by 115 people. Also as of October 4 2015, the project has 1704 open issues and 1476 closed issues.

The major releases and features added in those releases are mentioned in the below table.

Features

 * Multiplatform : It is available on major platforms like Windows, Mac, Linux etc.
 * Native implementation of web standards : Document Object Model, CSS , SVG , JavaScript and Canvas.
 * Pure headless on Linux : GUI is not needed for compiling and using PhantomJS in a system. This feature is useful for web service platforms and continuous integration systems.
 * REPL : Read Evaluate Print Loop is the feature which is an interactive model provided from version 1.5. Every line (Read) is sent to interpreter, which evaluates (Evaluation) and provides feedback (Print) immediately.

Usage

 * Headless Web Testing : This method is used for testing using command line without the need for browser. It supports multiple test frameworks like Jasmine (JavaScript framework) and QUnit.
 * Network Monitoring : It can be used to analyse network performance, track requests and responses during page loading and export as standard .har format.

Given example shows how to send a http post request to a test server

Given example shows how to search pizza places near Raleigh using yelp.com.
 * Web Page Automation : Automation can be done easily by loading and manipulating web pages using Document Object Model api.

Given example shows how to capture wikipedia home page and save it as an image.
 * Screen Capture : It can be used to capture the contents of a web page including HTML, CSS, SVG and canvas.

CasperJS
Shortly after the release of PhantomJS, Nicolas Perriault wrote CasperJS, a suite of libraries on top of PhantomJS that extend its capabilities as a client for automated web page testing. CasperJS and PhantomJS have become valuable enough that similar projects have started to adopt the API as a standard way of interacting with headless browsers.

YSlow
Yahoo! developed a version of YSlow that leverages PhantomJS for to gather performance metrics for websites.

Companies using PhantomJS

 * Twitter is using QUnit and PhantomJS for unit testing.
 * LinkedIn is using PhantomJS based tools for performance testing.
 * Netflix is using Sketchy, a headless browser built with PhantomJS to understand what it’s doing without having to visit the site.
 * Time Warner Cable is using PhantomJS with CoffeeScript, Jasmine, and JUnit XML for Jenkins continuous integration.

Other uses for PhantomJS
PhantomJS was made for programmatic control of web sites and has been used for many purposes from visual differencing of websites to automated testing of JavaScript frameworks.

Server Rendering of Client Side JavaScript
With the rise of client-side JavaScript and the SEO problems that practice presents, developers turned to PhantomJS as a way to pre-render static HTML for initial requests,. Despite the performance impact of such an approach, it remained one of the simplest ways to improve SEO without rewriting a web application, spawning services trying to automate the process.

Malicious use of PhantomJS
Because PhantomJS is runnable without a UI, scriptable via JavaScript, and is relatively adherent to modern browser specifications, it is commonly used as a way to automate attacks against web sites. PhantomJS mimics legitimate user traffic and can complicate attack mitigation technologies. PhantomJS can also be used to automatically verify logins across disparate web sites, compounding the problems that arise after a site is breached and usernames and passwords are leaked.

Open Source Projects Using PhantomJS

 * Bootstrap
 * CodeMirror
 * Ember.js
 * Grunt
 * Modernizr
 * YUI3
 * Zepto
 * Durandaljs

Books and Articles on PhantomJS

 * Book "Testable Javascript" by O'Reilly Media has a sub-chapter on PhantomJS page 95.
 * Book "PhantomJS Cookbook" by Packt publisher
 * Book "Getting Started with PhantomJS" by Pact publisher
 * Article on Threatpost mentioning PhantomJS in relation to security.