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.[2]
Original author(s) | Ariya Hidayat |
---|---|
Developer(s) | Ariya Hidayat |
Initial release | January 17, 2011 |
Final release | 2.1.1[1]
/ January 24, 2016 |
Repository | |
Written in | C++, JavaScript, C |
Type | Headless browser |
License | BSD[2] |
Website | phantomjs |
History
editPhantomJS was released January 23, 2011 by Ariya Hidayat after several years in development.[3]
The first commit to the public project was in 2011.[4]
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.[5]
Usage
editThe 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
editPhantomJS 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.[6] Similarly, trifleJS targeted the MSHTML engine of Internet Explorer.[7]
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.[8]
Yahoo! developed a version of YSlow that leverages PhantomJS to gather performance metrics for websites.[9]
Users
editSeveral notable companies have used PhantomJS.
- Twitter used QUnit and PhantomJS for unit testing as of 2015.[10]
- LinkedIn used PhantomJS based tools for performance testing as of 2011.[11]
- Netflix used Sketchy, a headless browser built with PhantomJS, to understand what it's doing without having to visit the site as of 2014.[12]
- Time Warner Cable used PhantomJS with CoffeeScript, Jasmine, and JUnit XML for Jenkins continuous integration as of 2012.[13]
See also
editReferences
edit- ^ "Releases · ariya/phantomjs". GitHub. Retrieved 21 April 2017.
- ^ a b "phantomjs/LICENSE.BSD at master · ariya/phantomjs". GitHub.
- ^ "don't code today what you can't debug tomorrow". ariya.blogspot.com. 23 January 2011. Retrieved 20 July 2015.
- ^ "ariya/phantomjs". GitHub. Retrieved 20 July 2015.
- ^ "Archiving the project: suspending the development". ariya/phantomjs. Github. 2018-03-03.
- ^ Laurent Jouanneau. "FaQ - SlimerJS". slimerjs.org. Retrieved 20 July 2015.
- ^ "trifleJS". Retrieved 20 July 2015.
- ^ "CasperJS on GitHub". GitHub. Retrieved 2021-04-11.
- ^ Marcel Duran. "YSlow - Official Open Source Project Website". yslow.org. Retrieved 20 July 2015.
- ^ "Leo Lanese on Twitter". Twitter. Retrieved 20 July 2015.
- ^ phegaro (11 October 2011). "LinkedIn Mobile: How do we do it?". SlideShare. Retrieved 20 July 2015.
- ^ Michael Mimoso (26 August 2014). "Netflix Open Source Security Tools Solve Range of Challenges". threatpost.com. Retrieved 20 July 2015.
- ^ "one year of wandering headlessly". ofilabs.com. Archived from the original on 22 July 2015. Retrieved 20 July 2015.