top | item 3738877

PhantomJS 1.5 released (headless WebKit with JavaScript API)

179 points| andrevoget | 14 years ago |code.google.com | reply

43 comments

order
[+] vitovito|14 years ago|reply
Wow. Congrats on finally going completely headless on Linux. That's a big deal.

This makes it the first modern browser replacement for our old moz-headless-screenshot branch, which is effectively Firefox 3.6. It's really a shame no-one's picked up that work for modern FF builds. Couldn't even find someone to hire for it...

[+] davedx|14 years ago|reply
Could you explain what this means exactly, going "headless"?
[+] DanielRibeiro|14 years ago|reply
No more support for Flash and other plugins

So sad to hear this. That was my main motivation for using PhantomJS. Fortunately 1.4 still supports it.

[+] veidr|14 years ago|reply
While it does kinda suck if your usecase needs Flash, I think the reasoning was solid. Being able to truly run headless in a barebones command line environment is more important than supporting Flash, in its waning years.

Then, of course, there's also this:

    Issues are reported but nobody volunteers to analyze or fix them
[+] wildmXranat|14 years ago|reply
When I use Selenium, I know the browser supports everything that the end user will and that includes, javascript evaluation, plugin loading, whatever.

To make a comparison for our heavy Selenium use, I can't clearly see what is lacking in PhantomJS that would be a show stopper.

Does anybody know if other than lack of Flash support, it covers all aspects of what the end user would experience ?

[+] lazerwalker|14 years ago|reply
The main advantage of Selenium is that it allows you to test cross-platform compatibility, since it can be configured to run on pretty much every major browser/OS combo.

For everything other than that, though, PhantomJS is fantastic. It's infinitely more pleasant to deal with than Selenium.

[+] metafeather|14 years ago|reply
If you are currently using Rhino to run Javascript then PhantomJS makes for an excellent and more functional replacement.

In addition to running library unit tests in a 'real' browser environment it can also be used to test apis and visual components, and then save results as files and screenshots for use with other systems such as Hudson.

I use it extensively for our web app build and test cycle at work (Causata.com) and to save time for anyone interested in rolling their own have made the code available on Github at https://github.com/metafeather/phantomjs-yuitest

[+] veidr|14 years ago|reply
I have been surprised that this project has seemed to fly under the radar for so long. It's extremely useful in a variety of scenarios, and as far as I know, it is unique in its capabilities.

I've used it to allow modern applications to interface with legacy systems that have no mechanism of extension, and no API other than their web interfaces. Just about anything you can control via a web interface, you (or your software) can control using PhantomJS.

[+] mk4p|14 years ago|reply
Could you give some examples? I'm very curious about these types of uses..
[+] ricardobeat|14 years ago|reply
It hasn't, it's well known around the javascript community.
[+] LogicX|14 years ago|reply
Anyone have a cheat sheet on using phantomjs as a drop-in replacement for wkhtmltopdf? http://code.google.com/p/wkhtmltopdf/

For the superior completely headless qualities? There was a post on HN almost 400 days ago where someone claimed wkhtmltopdf's PDF output quality was superior to phantomjs - anyone know if that's changed with this release?

[+] hengli|14 years ago|reply
I need to do some web crawling, how does this compare to jsdom on node.js? I'm using node.js of course.
[+] lazerwalker|14 years ago|reply
In my experience, using jsdom (and other similar node.js DOM libraries) is fine for scraping static content, but tends to fall down when you're dealing with anything that requires executing client-side JS. That's a big deal if you're scraping sites that load in content via XHR, or manipulate CSRF tokens in JS specifically to throw off static scrapers. Both of these are use cases that PhantomJS has handled beautifully for me in the past.
[+] MatthewPhillips|14 years ago|reply
Those are just scraping tools. phantom is a browser, what your scripts see are exactly what the user would see. Makes it great for test automation. Casperjs is a fork focusing on testing.
[+] weego|14 years ago|reply
I built a scraper that was nodejs and nowjs that sent instructions to a javascript bot I injected into the page rendered by phantomjs, the bot then scraped and sent snippets back to the server again via nowjs. The real win for me was it was a comet + ajax target which is usually hard to scrape efficiently but I just synced the bot with the comet updates and away we go. Also being headless I could just spin up 20 instances without any performance problems on a cheap rack server.
[+] jeromeparadis|14 years ago|reply
For example, if you need to scrape the DOM content for content loaded dynamically by JavaScript, PhantomJS will allow you to do the job. Or take snapshots of Web sites as they appear to users.
[+] scriptproof|14 years ago|reply
After having read the installation guide on Windows for Phantom.js and WebServer, that is embedded in it, apparently installing the first to use the second is a lot simpler!
[+] skeletonjelly|14 years ago|reply
Awesome. Was just looking for something like this yesterday to facilitate screenshots for an uptime script.
[+] sxtxixtxcxh|14 years ago|reply
we're upgrading to 1.5 now; be sure to read the build notes for linux, specifically: "do not simply copy the executable as it won't work."
[+] sxtxixtxcxh|14 years ago|reply
also, if you had built from the source previously, be sure to do a `git clean -xfd .` before running the ./build.sh
[+] boundlessdreamz|14 years ago|reply
Can phantomJS be run as a daemon?
[+] dkhenry|14 years ago|reply
I don't think it works like that. You write scripts for it and can use it to excersize web pages. I have used it extensively to test web sites.
[+] meow|14 years ago|reply
I usually use another controller program to launch it with required data..