setting up browser automation with FireWatir
Ruby-based testing will only get you so far in the web development world - sooner or later you need to make sure your code works in a real browser. So for the last few years I’ve been occasionally trying to get a browser-based test automation tool running - often something in the Selenium family. It usually takes a full day for me to give up, usually because I just can’t get the tool to actually drive the browser.
Today I got FireWatir working! It wasn’t that hard, but I had to consult a few different web pages, so here it is all in one place.
- Via FireWatir Installation, install the gem:
sudo gem install firewatir
and the
JSShFirefox extension (Mac FF 3.5 version) to make Firefox steerable. - Set up a Firefox profile, so you can run tests without all your weird extensions in play, and without messing with your personal browser session and history. Mine is called “tester”.
- Start up Firefox with JSSh and your new profile (you can do this while Firefox is running):
/Applications/Firefox.app/Contents/MacOS/firefox -jssh -P "tester"
- In an
irbsession, try some stuff - for example, on a new Spree instance:ff = FireWatir::Firefox.new ff.goto 'http://localhost:3000/' ff.link(:text, 'Clothing').click
Voila! Now I want to try Cucumber and Watir.