Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

barbie (2653)

  reversethis-{ku. ... m} {ta} {eibrab}

Leader of [] and a CPAN author []. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [] and the QA Hackathon [] websites. Also the current caretaker for the CPAN Testers websites and data stores.

If you really want to find out more, buy me a Guinness ;)

Memoirs of a Roadie []
CPAN Testers Reports []
YAPC Conference Surveys []
QA Hackathon []

Journal of barbie (2653)

Monday January 29, 2007
08:37 AM

Selenium & Perl & Win32

[ #32272 ]

For sometime I've been meaning to get Selenium to do all my page rendering testing. In Labyrinth I have command line testing built-in, so have mostly been relying on that. Having seen Luke Closs' presentation at YAPC::NA last year in Chicago, I was quite impressed by what he was saying it could offer. However, Luke's talk dealt more with what you could do with the application, rather than how to install and set it up.

I've just spent the last weekend trying to figure this very basic bit out. In the end it wasn't difficult, but as the documentation of how to set it all up is limited at best, and provides nothing of the 'what if this doesn't work' or 'I got this message, what does it mean?' type of FAQ documentation (or at least none that I could find), it got to be a little frustrating at times.

It took a while, but I did finally get it all installed and managed to get the remote control server to work. The biggest problem was actually trying to get it to work with Firefox. The solution was to scrape the idea of using Firefox and use Internet Explorer instead. While I have no doubt that Firefox may well be supported, the explanation of how to get it to work under Windows is nowhere to be found. The suggestion of adding the full path didn't work either. I'm hoping somwhere there is a simple explanation for using Selenium, Firefox and Windows, and maybe even someone reading this might be able to point me in the right direction, but until then I'll have to stick with the *iexplore route.

Once I'd finally got a working selenium server, I was able to set about writing my test cases. Only to hit another brick wall. All the example scripts I've seen, all mention a package called and function called server_is_running(). However, they don't exist in the CPAN downloads and are not part of any distribution. It brought back a few dependency hells I've seen with cpan-testing before now. After googling, I did find a copy of the package eventually, and stored it locally. I could then start writing my test scripts.

The docs for WWW::Selenium and Test::WWW::Selenium, while they might read well for someone who already knows Selenium, as a newbie, they could both really do with a beginners guide, together with a few example scripts that really do some basic things would go down well. After some trial and error and rereading the docs several times, I now have a simple test script that tests around 100 links on a small site I've done. Now that I know a bit more of how it all works, I'm going to start expanding my tests and start work on testing the admin processes too.

All this has made me realise what a goldmine Selenium is, and has left me wondering why there aren't half a dozen talks at YAPCs, etc. extolling the virtues of it. So I've decided to take at least one step in helping to change that. I'm going to work on a beginners guide to Selenium, which hopefully Luke won't mind adding to one (or both) of the Perl packages, and I'll also start work on a presentation to give an introduction to the application. It'll give me another presentation to offer to those attending the World Tour and YAPC::Europe too :)

So, seeing as there isn't alot of examples out there, does anyone have any local test scripts that you'd be willing to let me use to help expand an 'Introduction to Selenium' presentation?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Hi barbie,
    this code works quite well for me (Win XP + ActivePerl 5.8.8 + Selenium 0.27):

    use strict;
    use warnings;
    use Test::More tests => 2;
    use Test::WWW::Selenium;

    my $url = '';
    my $sel = Test::WWW::Selenium->new(
    host => 'localhost',
    port => 4444,
    browser => '*firefox',
    browser_url => $u
    • browser => '*firefox',

      That's the bit that doesn't work for me. It was driving me nuts yesterday, before I just gave up and reduced myself to using IE. Will have to check versions on my laptop, but it's XP and the latest version of Selenium, plus a 5.8 install of Perl. However, I suspect it to be a path thing, even though manually extending the path doesn't work either!