PhantomJS

{{Short description|Headless browser}}

{{Infobox software

| name = PhantomJS

| logo = Phantomjs-logo.png

| logo size = 240px

| author = Ariya Hidayat

| developer = Ariya Hidayat

| released = {{start date and age|2011|01|17}}

| latest release version = 2.1.1{{cite web|title=Releases · ariya/phantomjs|url=https://github.com/ariya/phantomjs/releases|website=GitHub|accessdate=21 April 2017}}

| latest release date = {{release date and age|2016|01|24}}

| programming language = C++, JavaScript, C

| discontinued = yes

| genre = Headless browser

| license = BSD{{cite web|title=phantomjs/LICENSE.BSD at master · ariya/phantomjs|url=https://github.com/ariya/phantomjs/blob/master/LICENSE.BSD|website=GitHub|language=en}}

| website =

}}

PhantomJS is a discontinued 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.{{cite web|url=http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html|title=don't code today what you can't debug tomorrow|work=ariya.blogspot.com|date=23 January 2011 |accessdate=20 July 2015}}

The first commit to the public project was in 2011.{{cite web|url=https://github.com/ariya/phantomjs|title=ariya/phantomjs|work=GitHub|accessdate=20 July 2015}}

The logo commonly used to pictorially refer to PhantomJS is a fluorescent blue ghost atop a black background. This refers to the lack of graphical user interface, or main body of the browser, making PhantomJS users seem like ghosts.

In March 2018, the development of PhantomJS was suspended due to lack of active contributions.{{cite web|url=https://github.com/ariya/phantomjs/issues/15344|publisher=Github|title=Archiving the project: suspending the development|date=2018-03-03|work=ariya/phantomjs}}

Usage

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();

});

Ecosystem

PhantomJS became valuable enough that similar projects adopted the API as a standard way of interacting with headless browsers. SlimerJS provided a PhantomJS-like API, but on top of Mozilla's Gecko browser engine rather than WebKit.{{cite web|url=http://slimerjs.org/faq.html|title=FaQ - SlimerJS|author=Laurent Jouanneau|work=slimerjs.org|accessdate=20 July 2015}} Similarly, trifleJS targeted the MSHTML engine of Internet Explorer.{{cite web|url=http://triflejs.org/|title=trifleJS|accessdate=20 July 2015}}

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, allowing users to create BDD tests leveraging PhantomJS. The final release of CasperJS was in 2017.{{cite web|url=https://github.com/casperjs/casperjs|title=CasperJS on GitHub|website=GitHub|access-date=2021-04-11}}

Yahoo! developed a version of YSlow that leverages PhantomJS to gather performance metrics for websites.{{cite web|url=http://yslow.org/phantomjs/|title=YSlow - Official Open Source Project Website|author=Marcel Duran|work=yslow.org|accessdate=20 July 2015}}

Users

Several notable companies have used PhantomJS.

  • Twitter used QUnit and PhantomJS for unit testing as of 2015.{{cite web|url=https://twitter.com/leolaneseltd/status/197766152745787392|title=Leo Lanese on Twitter|work=Twitter|accessdate=20 July 2015}}
  • LinkedIn used PhantomJS based tools for performance testing as of 2011.{{cite web|url=http://www.slideshare.net/phegaro/linkedin-mobile-how-do-we-do-it|title=LinkedIn Mobile: How do we do it?|author=phegaro|work=SlideShare|date=11 October 2011 |accessdate=20 July 2015}}
  • Netflix used Sketchy, a headless browser built with PhantomJS, to understand what it's doing without having to visit the site as of 2014.{{what|reason="to understand what [Netflix]'s doing without having to visit [Netflix]" is how this sentence reads, and this a) makes no sense and b) is not what the reference says at all|date=March 2025}}{{cite web|url=http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931#sthash.pcyW3Ksf.dpuf|title=Netflix Open Source Security Tools Solve Range of Challenges|author=Michael Mimoso|work=threatpost.com|date=26 August 2014 |accessdate=20 July 2015}}
  • Time Warner Cable used PhantomJS with CoffeeScript, Jasmine, and JUnit XML for Jenkins continuous integration as of 2012.{{cite web|url=http://ariya.ofilabs.com/2012/01/one-year-of-wandering-headlessly.html|title=one year of wandering headlessly|work=ofilabs.com|accessdate=20 July 2015|archive-date=22 July 2015|archive-url=https://web.archive.org/web/20150722045918/http://ariya.ofilabs.com/2012/01/one-year-of-wandering-headlessly.html|url-status=dead}}

See also

{{Portal|Free and open-source software}}

References

{{Reflist}}