[BangPypers] Functional testing wih headless browser framework

Amber Jain i.amber.jain at gmail.com
Wed Sep 25 07:11:33 CEST 2013


Hello,

> > On 17 September 2013 02:24, Amit Sethi <amit.pureenergy at gmail.com>
> > wrote:
> > > > Hi ,
> > > >
> > > > I am looking to add some functional testing to my application. I have
> > > seen
> > > > a couple of tools via google search but the reason I am a little
> > > > circumspect is that last time, I did something similar using selenium
> > and
> > > > it seemed lack some requirements of mine.(It was not exacty headless)
> > > [...]
> >


Am I late to the party? :)

Thanks to many useful replies, we have so many alternatives to choose from:
Selenium, PhantomJS, SlimerJS, CasperJS, ZombieJS, Splinter and many
others. But here's a highly opinionated email advocating Selenium.

Most of the alternatives to Selenium do functional testing. But Selenium
does *cross browser* functional testing. For e.g. PhantomJS does headless
WebKit. But what about browsers that don't use WebKit? What about Mozilla
(which uses Gecko) or IE (which uses Trident)? To be precise, even
PhantomJS uses QtWebKit (https://github.com/ariya/phantomjs/issues/11074).
This means that PhantomJS's JavaScript engine is different from the one
used by Chrome. For many small projects, this probably does not matters a
lot. However, if you have a large user base with diverse browser
preferences, you need to do cross browser functional testing (at least for
all the browsers you claim to support), and for this you need 'real' web
browsers.

Even though one of my favorite xkcd strip mocks Standards (
http://xkcd.com/927/), Selenium WebDriver is on the path to become a W3C
standard now (a W3C working draft was released few months ago
http://www.w3.org/TR/webdriver/). So, being a standard, Selenium will steal
the show whenever it comes to cross browser functional testing (even though
other alternatives beat Selenium in many use cases).
Moreover, development on other alternative projects *might* stall due to
lack of contributors or inactivity. But we can 'expect' that W3C,
Selenium/WebDriver team and browser vendors will actively develop/support
Selenium WebDriver (I say 'expect' because many browser vendors introduce
incompatible extensions to standards).

One disadvantage of using Selenium is that it is slower than other
alternatives (as it actually fires up a web browser and browsers are slow
beasts!) There are use cases, other than functional testing, when using
Selenium will be overkill and a  waste of resources (such as automating
boring web administration tasks). It is upto you to decide whether you want
100% coverage on functional testing front (with Selenium's cross browser
support) or you want to save resources/money at the expense of <100%
functional testing coverage (by using other alternatives).

@Amit: Selenium fulfills all your stated requirements (It runs JS in a real
web browser, supports headless mode with Xvfb, has CLI, integrates well
with popular/most CI and testing tools).
If 'headless-less' ;-) Selenium was the only reason that forced you to look
into alternatives, you can use Selenium in headless mode using Xvfb (as
many others had already said). Here's a bash script to setup
Selenium/Xvfb/Chrome for you (works at least on Ubuntu 12.04):
https://gist.github.com/amberj/6695353 (If you need to do functional
testing on some other web browser, install it and it's Selenium driver
instead of Chrome/ChromeDriver).

Hope this helps!

-- 
Amber Jain
i.amber.jain at gmail.com
http://amberj.devio.us/


More information about the BangPypers mailing list