Watir on Windows XP – Installation
Watir – Web Application Testing in Ruby – I’m thinking about adding this as part of my standard Rails integration tests. I like the idea of capturing keystokes that a user might actually run. Plus, it makes for a dandy demo tool.
Here’s the summary of installation steps. I’m assuming you’re Rails-aware enough to have an application in place, and you know how to install Ruby gems:
Rails Side -
gem install watir
gem install tg4rb
Firefox Side -
Install the TestGen4Web add-on
Install the JSSH extension – start here to determine which version, and follow all the instructions on the page.
Once you restart Firefox, the TestGen4Web icon should be in the lower right hand corner – you click on that to bring up the tool bar. Then it’s just a matter of starting the record, capturing the keystrokes, stop recording, and then save the captured keystrokes to a file. The content will be XML, so use a .xml extension.
From the command line – sorry, Command Prompt window in MS-speak, run tg4rb on the file you saved: tg4rb /tmp/mykeystrokefile.xml – you will get a mykeystrokefile.rb in the same folder location.
Then run ruby mykeystrokefile.rb, and watch the magic.
I’ll add another blog about actually using this stuff, and I also need to see if I can do this on a Linux machine. Stay tuned.
PS – I can’t believe it’s been a month since my last blog. What a slacker. 8>)
You can do it very simple on a Linux machine. I’m using it on Ubuntu 9.04 and it works fine.
Using the right jssh extension is important. See my posting in the watir-general. http://tr.im/mIXG
on windows i’m also using webmetrics Ria scriptrecorder. http://tr.im/mIYK
I like the rb output file from this scriptrecorder and prefer it above tg4rb.
Hi Richard, thanks for the tip. The Webmetrics app is quite good, I’ll need to play with it a bit more. The Rails app I’m testing is almost pure AJAX, and nothing is working in that environment without a lot of manual hacks on the generated Ruby code, whether it’s from Scriptrecorder or tg4rb. I’ll publish my findings after I run some more evaulations. Thanks again for responding.