PhantomJS
Original author(s) | Ariya Hidayat |
---|---|
Developer(s) | Ariya Hidayat |
Initial release | January 17, 2011 |
Stable release | 2.0.0 / January 23, 2015 |
Development status | Active |
Written in | C++ |
Type | Headless browser |
License | BSD |
Website |
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.[1]
The first commit to the public project was in 2011.[2] The project has maintained a steady level of weekly contributions from December 26, 2010 to present.[3] As of February 5, 2015, the project’s open source code repository is watched by 770 people and contributed to by 107 contributors. Also as of February 5, 2015, the project has 1376 open issues and 1252 closed issues.
The logo commonly used to pictorially refer to PhantomJS is a green 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.
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(); });
Tools using PhantomJS
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.[4][5]
YSlow
Yahoo! developed a version of YSlow that leverages PhantomJS for to gather performance metrics for websites.[6]
Companies using PhantomJS
- Twitter is using QUnit and PhantomJS for unit testing.[7]
- LinkedIn is using PhantomJS based tools for performance testing.[8]
- Netflix is using Sketchy, a headless browser built with PhantomJS to understand what it’s doing without having to visit the site.[9]
- Time Warner Cable is using PhantomJS with CoffeeScript, Jasmine, and JUnit XML for Jenkins continuous integration.[10]
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 [11] to automated testing of JavaScript frameworks.[12]
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,.[13][14] 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.[15]
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.[16] PhantomJS mimics legitimate user traffic and can complicate attack mitigation technologies. PhantomJS can also be used to automatically verify logins across disparate web sites[17] (Credential Stuffing), compounding the problems that arise after a site is breached and usernames and passwords are leaked.
Books, Classes and Articles on PhantomJS
- O'Reilly Media published book "Testable Javascript"[18] has a sub-chapter on PhantomJS page 95.
- Packt published book "PhantomJS Cookbook"[19]
- Packt published book "Getting Started with PhantomJS"[20]
- Article on Threatpost mentioning PhantomJS in relation to security.[21]
- Stanford course syllabus mentioning PhantomJS on "Final Project: Grading" slide.[22]
- Sitepoint published a guide on headless webkit and PhantomJS [23]
- Article on Smashing Magezine mentioning PhantomJS to generate SVP with javascript
- Researchers use PhantomJS to construct crawler for social network analysis [24][25]
See also
- SlimerJS
- TrifleJS
- CasperJS
- Selenium (software)
- Webkit
- Google chrome
- Firefox
References
- ↑ http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html
- ↑ https://github.com/ariya/phantomjs
- ↑ https://github.com/ariya/phantomjs/graphs/contributors
- ↑ http://slimerjs.org/faq.html
- ↑ http://triflejs.org/
- ↑ http://yslow.org/phantomjs/
- ↑ https://twitter.com/leolaneseltd/status/197766152745787392
- ↑ http://www.slideshare.net/phegaro/linkedin-mobile-how-do-we-do-it
- ↑ http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931#sthash.pcyW3Ksf.dpuf
- ↑ http://ariya.ofilabs.com/2012/01/one-year-of-wandering-headlessly.html
- ↑ https://github.com/Huddle/PhantomCSS
- ↑ http://durandaljs.com/documentation/Testing-With-PhantomJS-And-Jasmine.html
- ↑ http://eshlox.net/2014/05/04/short-story-about-rendering-html-client-side-vs-server-side/
- ↑ http://blog.42floors.com/sever-side-rendering-single-page-apps-using-phantomjs-node-js/
- ↑ http://www.brombone.com/
- ↑ http://www.darkreading.com/attacks-breaches/ddos-attack-used-headless-browsers-in-150-hour-siege/d/d-id/1140696?
- ↑ https://gist.github.com/dariusk/4072489
- ↑ https://books.google.com/books?id=hjE767CCeQwC&printsec=frontcover&dq=phantomjs&hl=en&sa=X&ei=ngPcVJuqA83YoATrq4EY&ved=0CEoQ6AEwCA#v=onepage&q=phantomjs&f=false
- ↑ https://www.packtpub.com/web-development/phantomjs-cookbook
- ↑ https://www.packtpub.com/web-development/getting-started-phantomjs
- ↑ http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931
- ↑ http://www.scribd.com/doc/151866935/Stanford-University-Startups-Engineering-course#scribd
- ↑ http://www.sitepoint.com/headless-webkit-and-phantomjs/
- ↑ http://www.wseas.org/multimedia/journals/communications/2014/a165704-469.pdf
- ↑ http://www.ccs.neu.edu/home/amislove/publications/Pinterest-ICWSM.pdf
External links
|