ci_reporter output for Watir
I’ve been using the ci_reporter gem to grab the results from my Test::Unit verifications and put them in an xml file. Then I apply an xsl stylesheet to the xml to transform the results into html. It’s not the prettiest report, but it beats reading xml or parsing through command line output. My goal is to move my test framework to a rails app for better reporting and data management, but for now, I’m sticking with the ci_reporter output. Here’s how it works:
First you need to install the ci_reporter gem and require the ci_reporter rake task in your framework class (in my case in my Test::Unit class):
require 'ci/reporter/rake/test_unit_loader'
After running your framework, ci_reporter will create ‘test/reports’ subdirectories and place the xml output of your tests in the reports folder.
Next, you’ll need to transform this xml output to html. This is accomplished by applying an xsl stylesheet to your xml. I’ve saved my stylesheet text as a doc file here:
https://tcfodor.files.wordpress.com/2009/04/transform-results.doc
To apply the stylesheet, add the following at line 2 of your xml output:
<?xml-stylesheet type="text/xsl" href="transform-results.xsl"?>
In my case, I just make sure the stylesheet is saved in the local directory. If you want to save it somewhere else, you’ll need to supply a relative path.
As part of my framework, I’ve automated updating the xml output and renaming it with a test run. Then it saves the xml output and xsl transform to a network location to share with the rest of the team.
This assumes that IE is your browser of choice, to view the report in Firefox, add the following line to your xml output at line 3.
<xsl:if test="system-property('xsl:vendor')='Transformiix'"></xsl:if>
Watir Podcast #23 – turning the table on Zeljko
I recently had the pleasure of recording a Watir Podcast with Watir Core Team member Zeljko Filipin. You can find it at http://watirpodcast.com/23-zeljko-filipin/ Zeljko (aka Z*) is very involved with the Watir community and has been recording Watir podcasts for a year now.
watir-console, my new best friend
I’ve made the move from irb to watir-console for troubleshooting Watir code.
Since version 1.5.2, watir-console has been part of the Watir installation. Basically, it’s an irb session on steroids. It’s launched through a regular console the same way irb is (c:\>watir-console), but it also includes the following:
- a local log of your session (saved as console.log)
- tab complete functionality
- does require ‘watir’ automatically
Jim Knowlton has a great example of adding helper class functionality to watir-console so that any classes or methods you want can be automatically available when you launch watir-console.
http://www.agilerubytester.com/2009/02/customizing-watir-console.html
Pair watir-console with an HTML element inspector like Firebug (for Firefox) or IE Developer Toolbar, and you have a great environment for testing and troubleshooting watir tests.
Our coolest project ever
A few years ago, my husband traded a 40’s-era Chrysler hubcap that he had hanging in our garage for an old Pepsi machine. The guy he traded had an old Chrysler and had been looking high and low for the one hub cap he was missing. Plus, he had stocked the soda machine with beer and was tired of his son’s college-age friends’ raiding it. We felt guilty, but he considered it a fair trade.
The soda machine languished in a corner of our garage until our beer fridge died last summer. We pulled it out of the corner, crossed our fingers and plugged it in – it fired up like new! It needed a paint job, so John painted the body and my Mom painted the new logo. I wired it to bypass the broken coin mechanism and voila! – we have the most excellent soda beer machine I’ve ever seen.

Props to Mom and John for the paint!
PMI TMI
There’s a certification that project management professionals can get from the aptly-named Project Management Institute. It’s one of the more popular certifications, and as I understand, it’s not easy. To be certified, you have to go to a lot of classes, work as a PM professional and keep the certification up-to-date.
The worst PMs I’ve worked with have been PMI-certified. There. I said it. I said it, and here’s why…..
I don’t believe that the PMI is teaching bad techniques – I’m sure they’re very valuable. However, these techniques should not be applied as cookie-cutters at the expense of common-sense and an awareness of the project at hand. They shouldn’t be thrown up as hurdles for the sake of clearing them so that the PM can mark something off a checklist they got from a class. Some people understand this and use what they learned at PMI as it makes sense. Others don’t and try to shoehorn a project into their view of what every project should be.
I’m not saying that everyone with PMI certification should be avoided. On the contrary, I’ve worked with great PMs who have PMI certification. However, all of the worst PMs I’ve worked with have it and some of the very best have no certifications at all. The best PMs understand that most of what they do is probably transparent to the rest of the group – things go smoothly because they’re clearing the road.
For me, a PMI certification in a signature line is a flag that this person could be trouble. Often, I’m happily surprised when they turn out to be great. It’s like any other certification – not a substitute for good experience and natural ability.
(I’ll leave software test certifications for a whole other rant.)
Multiline comments in Ruby.
Maybe the Google failed me, maybe I was just not being observant, but when I first started using Ruby, I could not for the life of me figure out how to make multiline comments. I had resorted to using lots of # signs, which isn’t especially difficult, but it just felt like there had to be an easier way.
Turns out, there is an easier, although perhaps still a bit clunky, way. To start a multiline comment put =begin before the first line of comments and =end after the last line. Note that these commands can not be indented at all, you have to put them at the beginning of the line.
IRB is your friend.
They say that there’s no such thing as a dumb question, but we’ve all asked questions that we wish we could take back. That’s why IRB and watir-console are so great when you’re writing Watir tests- you get to try out any command (or even a group of commands) to quickly see if it works without having to ask someone else or run your whole test. The best part is that, unlike a post to a group, any totally off base attempts are not available for the world to see.
Think of IRB as a buffer for embarrassing questions. Learn it, use it, love it.
From a command prompt:
C:>irb irb(main):001:0> require 'watir' => true
irb(main):002:0> browser = Watir::Browser.new => a bunch of output describing the browser irb(main):003:0> browser.goto('http://www.google.com') => 1.115
irb(main):004:0> browser.text_field(:name, 'q').set('watir information') => ""
If I try something that doesn’t work, I get a helpful error message:
irb(main):005:0> browser.text_field(:name, 'qwerty').set('watir information') =>Watir::Exception::UnknownObjectException: Unable to locate element, using :name, "qwerty"