Software:PhantomJS

From HandWiki
Revision as of 08:10, 9 February 2024 by Unex (talk | contribs) (link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Headless browser
PhantomJS
Phantomjs-logo.png
Original author(s)Ariya Hidayat
Developer(s)Ariya Hidayat
Initial releaseJanuary 17, 2011; 13 years ago (2011-01-17)
Final release
2.1.1[1] / January 24, 2016; 8 years ago (2016-01-24)
Written inC++, JavaScript, C
TypeHeadless browser
LicenseBSD[2]

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]

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]

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

  • 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

References

  1. "Releases · ariya/phantomjs". https://github.com/ariya/phantomjs/releases. Retrieved 21 April 2017. 
  2. 2.0 2.1 "phantomjs/LICENSE.BSD at master · ariya/phantomjs" (in en). https://github.com/ariya/phantomjs/blob/master/LICENSE.BSD. 
  3. "don't code today what you can't debug tomorrow". ariya.blogspot.com. 23 January 2011. http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html. Retrieved 20 July 2015. 
  4. "ariya/phantomjs". GitHub. https://github.com/ariya/phantomjs. Retrieved 20 July 2015. 
  5. "Archiving the project: suspending the development". ariya/phantomjs. Github. 2018-03-03. https://github.com/ariya/phantomjs/issues/15344. 
  6. Laurent Jouanneau. "FaQ - SlimerJS". slimerjs.org. http://slimerjs.org/faq.html. Retrieved 20 July 2015. 
  7. "trifleJS". http://triflejs.org/. Retrieved 20 July 2015. 
  8. "CasperJS on GitHub". https://github.com/casperjs/casperjs. 
  9. Marcel Duran. "YSlow - Official Open Source Project Website". yslow.org. http://yslow.org/phantomjs/. Retrieved 20 July 2015. 
  10. "Leo Lanese on Twitter". Twitter. https://twitter.com/leolaneseltd/status/197766152745787392. Retrieved 20 July 2015. 
  11. phegaro (11 October 2011). "LinkedIn Mobile: How do we do it?". SlideShare. http://www.slideshare.net/phegaro/linkedin-mobile-how-do-we-do-it. Retrieved 20 July 2015. 
  12. Michael Mimoso (26 August 2014). "Netflix Open Source Security Tools Solve Range of Challenges". threatpost.com. http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931#sthash.pcyW3Ksf.dpuf. Retrieved 20 July 2015. 
  13. "one year of wandering headlessly". ofilabs.com. http://ariya.ofilabs.com/2012/01/one-year-of-wandering-headlessly.html. Retrieved 20 July 2015. 

External links