[python-uk] Lightweight headless browsers (was Re: Dojo / workshop on "TDD Django with Selenium" - any interest?)

John J Lee jjl at pobox.com
Fri Oct 21 02:55:47 CEST 2011


On Thu, 13 Oct 2011, Andy Robinson wrote:

> On 13 October 2011 17:26, Harry Percival <harry.percival at gmail.com> wrote:
>> Hi-ho python peeps,
>>
>> Would anyone be interested in a dojo / worksop on the topic of test-driven
>> Django development, with Selenium?
>>
>> So, trying to get an idea of numbers - would anyone be interested?  London
>> area, venue suggestions also gratefully accepted...
>
>
> This could be highly relevant for us and of my clients.  Possibly 5
> people from us if the timing is right.

Has anybody else experimented with PhantomJS yet?  It's essentially 
QtWebKit plus a thin wrapper.  Though it does still need an X server 
currently, that's easily met with xvfb-run.  I've recently started using 
it, and it seems well suited to both TDD and functional testing.  I like 
that when a test fails and I drop into PDB (leaving my web server test 
fixture -- which is relatively slow to set up and tear down -- running in 
a subprocess) I can run the entire browser set up, test execution and tear 
down in under 1 second.  I also like the fact that there's a very 
convenient one-liner to dump a PDF "screenshot" of the rendered web page. 
With selenium, though you can leave the browser running, I always found it 
rather slow to develop tests and debug failing tests -- that hasn't beeen 
the case with PhantomJS so far, though it's early days still.  I should 
note I am likely being unfair to selenium here because the tests I'm 
writing are relatively small compared to the selenium tests I worked on 
before.  But not all that unfair, I think.  I guess I should also state 
the obvious: selenium still has an important role because it supports 
multiple web browsers.

I'd be interested to hear people's experience of zombie.js, envjs, and 
HtmlUnit for testing -- in particular, whether you've had to make any 
changes to your existing JavaScript code.  Not having to do so is the most 
obvious draw of PhantomJS over those tools, but perhaps I'm being hard on 
them?

I've been waiting for this kind of thing for about seven years (even 
started work on one myself back then), so it's great to see all these 
lightweight headless browsers appear.

Anybody considered doing something like capybara in Python?  It provides 
implementations of a common API for most of these systems (including 
PhantomJS, envjs and selenium I think).


John


More information about the python-uk mailing list