Top Qs
Timeline
Chat
Perspective

PhantomJS

Headless browser From Wikipedia, the free encyclopedia

PhantomJS
Remove ads

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]

Quick Facts Original author(s), Developer(s) ...
Remove ads
Remove ads

History

PhantomJS 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]

Remove ads

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();
});
Remove ads

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.[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

Several notable companies have used PhantomJS.

Remove ads

See also

References

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads