Scott Hanselman

Introducing WatirMaker - Recording for Ruby-based Watir

July 27, 2005 Comment on this post [10] Posted in ASP.NET | Ruby | Screencasts | Speaking | Watir
Sponsored By

Watirmaker01Well, my wife is out of town and as usual, I can't sleep at all. We've been married 5 years and we just can't sleep separate. This is both a good and a bad thing. Bad because it's 3:23am, good because I felt compelled to write some software.

I've been digging Watir lately and have introduced it around work. The question that everyone keeps asking is "ok, so how do I automatically record Watir scripts" and the answer has been, to the best of my knowledge, "um, you don't. Hopefully someone will do something soon."

I got tired of waiting. I started at 10pm and now it's 3:25 and Conan is being repeated. So, here's a screencast of my results after 5.5 hours. It's very rough but it supports text boxes, buttons, links, select lists (kinda), radios and checkboxes. It doesn't support frames, iframes, the back button, divs, tables, etc yet. It's also very sloppy code, so I think what I'm going to do is get a few volunteers in the Watir community who are also .NET savvy to help me out and I'll try to release it in a week or so.

There's some really crazy stuff going on in here with UCOMIConnectionPoint in order to get "IE on a string." Also, a lot of things are being caught on the onfocusout event. I also need to understand if HTMLDocumentEvents2 is the right object model to be watching.

If there's interest, we shall see. Interested? Here's the screencast of WatirMaker 0.1. I'm off to bed.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 27, 2005 15:50
Very cool.

Your post 'Integrating Ruby and Watir with NUnit' is what put me onto Watir (thanks by the way): In a weird confluence of events, your post came out, I got involved as a reviewer for a scripting for testers book (I didn’t know initially but the book features Ruby as the scripting language), and I was also watching the Rails media wave. This trinity got me to play with Watir – and got hooked – as well as Rails. Ruby quite rocks.

At that time I had Selenium running our GUI tests but found some shortcomings on that tool specific to the way my company required us to work.

We're in mid-switch on a major release, running old tests with selenium and writing new ones with Watir and converting the old ones when they break. This type of recording feature would make a solid option even better.

Definitely hope to see this come to pass.
July 27, 2005 18:40
The yellow highlighting in the browser during playback is sweet.
July 27, 2005 19:14
Thats pretty damn cool.
One question, (and completely offtopic) what the calendar on your desktop?
July 27, 2005 20:25
Nice work Scott. I can never sleep away from my wife either. How long did you say you spent writing this? I keep trying to convince the testers at work to ditch commercial-gui-automated-testing-tool-that-makes-you-use-VBA-for-automation for something like this.
July 27, 2005 21:20
The calendar on my desktop is the InkDesk stuff that comes with the TabletPC Experience Pack

I sent 5.5 hours on it. Believe me, the code is ALL f'ed up, but it works to "sketch" a site.
July 28, 2005 10:25
Very interested, Scott. I have been working with similar tools for SAMIE and Perl's Win23::GUITest.

BTW, Jason, I think the yellow flashing you talk about is Watir functionality.
July 28, 2005 13:20
Hi Scott,

This is great work! Your original Watir post got me thinking about how you could use Watir to drive the automation of IE, but perform your assertions in .NET.

My idea was to use Ruby simply as the automation engine – you’d call your scripts using a .NET wrapper, pass back the contents of the final HTML document via the process.StandardOutput, then use the HTML Agility Pack (see http:// blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx and http:// smourier.blogspot.com/) to load the document and then perform XPath queries (built using a tool like http:// www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=4f976e6e-9474-4813-b1cd-5e565f3219f9) against the HTML DOM to validate that the HTML elements are in the correct state (using Assert.IsTrue etc) rather than having to write the assertions in Ruby then use regular expressions to parse the output.

Unfortunately I’m totally maxed out working on a Scrum Methodology plug-in for Team System and have absolutely zero time to get this working…
July 30, 2005 11:51
Hi Scott,

How come few of ur icons(shorcuts) showing Firefox's ICON in ur desktop???/

August 04, 2005 12:19
Great, the ideas always become programs to high hours of the dawn...
Carlos.
August 24, 2005 22:06
Been waiting and thinking of making something like this for Watir for quite sometime now. Your code gives me a huge jump in this regard. Best of all, its in C#. Buhahhahaha, lovely!


Gotta extend it... I hope there is no restriction on modifying the code for non-commercial reasons to speed up writing scripts process?

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.