ariya.io About Collections Archives

PhantomJS 1.8 "Blue Winter Rose"

2 min read


Photo by christopher goodband CC BY-SA 2.0.

Winter is coming. The recent December solstice occurred on Dec 21 where I also tagged version of 1.8.0 of PhantomJS, headless WebKit for page automation. The code name for this release is Blue Winter Rose, as chosen by Ivan:

Bael the Bard climbed the Wall.

Took the Kingsroad and entered Winterfell.

He made himself known as Sygerrik of Skagos, a singer.

He sang until midnight for the Lord’s pleasure.

Impressed by his skills, Lord Brandon Stark asked him what rewarded he wanted.

Bael asked for the most beautiful flower in Winterfell’s gardens.

Blue winter roses were just blooming.

Brandon Stark agreed to offer him one.

One of major highlights in this 1.8 release is the integration of Ivan’s excellent project Ghost Driver. It is an implementation of WebDriver Wire Protocol on top of PhantomJS. Selenium users might be excited because now there is also an easy way to run your tests without launching a browser. Thanks to the integration, setting up PhantomJS as a remote WebDriver is ridiculously trivial:

phantomjs --webdriver=9134

You can control this from many different environments, from Ruby to Java. As also mentioned in the release notes, here is a Ruby example (pardon my slight deviation from the classic Cheese example):

require "selenium-webdriver"
driver = Selenium::WebDriver.for(:remote, :url => "http://localhost:9134")
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "PhantomJS"
element.submit
puts driver.title
driver.quit

Here is another simpler example in JavaScript using Node.js and the WebDriver module:

var wd = require('wd');
var driver = wd.remote('localhost', 9134);
 
driver.init(function() {
    driver.get("http://casperjs.org", function() {
        driver.title(function(err, title) {
            console.log(title);
        });
    });
});

Because of the setup, running via PhantomJS is typically faster for many types of test scenarios. Of course, it does not eliminate the need for a comprehensive cross-browser testing. Rather, use it as an additional development helper, particularly with the strategy of multiple layers of defense.

Last but not least, here is the chart comparing the total downloads of some recent releases.

I’m fairly sure that some of the downloads are caused by automatic PhantomJS installation for some continuous integration workflow. Nothing is wrong about that of course. On the other hand, looking at tons of recent blog posts/articles about PhantomJS, obviously we get more and more (happy) users.

Many thanks to everyone who contributed to this release. You guys rock!

Related posts:

♡ this article? Explore more, check the archives, or follow me Twitter.

Share this on Twitter Facebook Google+

comments powered by Disqus