WTANZ 09: Spidering Australia’s National Toilet Map with Watir

toilet sign
Image via Wikipedia

This month, Weekend Testing Australia-New Zealand was happy to welcome Trish Khoo as our guest facilitator.  Trish writes the blog Purple Box Testing and works with another test blogger, James Martin (The beaches here in Australia are awash in excellent software testing bloggers…who knew!)

We seem to have a thread going around Watir and Ruby (likely to be continued next month) which Trish helped to push a little farther with this month’s project.  Whenever Trish is writing automation, she finds it helpful to get a few files containing lists of controls for the pages being tested.  Our mission was to use whichever framework we had handy (duh! Watir) to create files containing some lists of the elements, such as links and buttons, on each page.  The application we used was the very practical National Public Toilet Map of Australia. (I hear there’s an iPhone app for this.)

I guess this doesn’t sound too much like a garden variety Weekend Testing topic, it’s pretty involved and isn’t immediately testing (like with our brains) but this has been one of the most interesting sessions I think we’ve had in a couple of ways:

  1. It’s giving me something practical to try with Ruby and Watir, and gets me into looking at the content on a page or set of pages.  This isn’t necessarily system testing, but being able to get meta-data out of a SUT about the elements it contains could be an entry point to asking questions.  I am all about asking questions in as many different ways and from as many different perspectives as possible.  At some point I want to look at how I can do this at work where I use Selenium and Java.
  2. The conversation between Trish and Oliver (Oliver Erlewein is another WTANZ facilitator) was fascinating.  I ended up not asking too many questions because I wanted to see where they would take their conversation.

Here is the transcript.

Since I’m not that familiar with Ruby, I had to abstract mine down to something I could accomplish in an hour.  I was able to get a list of links from the page into an array.  Although getting lists of all of the different types of controls such as buttons and checkboxes was beyond the scope of what I could do, Watir seems to have plenty of methods for these (here is the api.  In restricting myself to links I searched through the Watir Google Group and found a link to this page on Collections of HTML Elements in the Watir CONFLUENCE Wiki.  The example made getting an array of links a fairly trivial task.

While I didn’t end up with the script that Trish was describing, I kept working on this mission well past our allotted 2 hours.

I’ve thrown some of the commands I used into a gist on Github.  (don’t judge the crappiness…just don’t)  I know that ruby scripts are easy to make, but I’ve had some issues getting my browser to work with scripts, so I’ve just been using irb.  Maybe I’ll do some work on that in the next month.

Switching WTANZ to being monthly is much more sustainable and seems to be working out.  Preparing an interesting topic every other week, as we were doing previously, is not an easy task.  I admire the Europe Weekend Testers for consistently coming up with the fascinating topics that they do on a weekly basis.  We might eventually steal some of them for use down here in the Southern Hemisphere.  Oliver was hinting at some Cucumber for our next session and I’m still turning over Model-Based testing and some other extremely non-trivial ideas for sessions.

Enhanced by Zemanta

6 thoughts on “WTANZ 09: Spidering Australia’s National Toilet Map with Watir”

  1. My 2 thoughts on that:

    1. This might be too ideal for real life, but it’s great to think of having a layer of abstraction from the testing framework so that it doesn’t matter if it’s Selenium or Watir, we’re just accomplishing what we need to with the framework whether that’s creating test data, playing with our pages or looking for a job.

    2. One of my reasons for sticking with Ruby is that I don’t think Java is the way forward for this type of testing. From the limited reading I’ve done, Ruby is much more set up to deal with meta-data. For that reason, I’d rather be using ruby with any testing framework. Your script shows me that it’s perfectly viable to use it with Selenium. That’s something I was googling this weekend.

  2. hmm… looks like i missed WTANZ this weekend…
    good interesting stuff happening over WTANZ past 2 sessions…
    i will remind myself for next session in October…

Comments are closed.