Two powerful tools for communicating requirements from your customers, and testing those requirements, are
Fitnesse and
Selenium. Fitnesse, a wiki encapsulating the Framework for Integration Tests (aka FIT), enables customers to write sentence-like tests which can be mapped to the underlying system. Selenium drives a browser without all of the fragile mouse coordinate testing you get from a lot of testing tools (ala WinRunner).
While there's
been a lot of
good posts on Fitnesse and Selenium, none of them seemed to fit in to exactly what we need, which was a way for our customers to harness the power of Selenium in the acceptance tests they are writing. So, using the
DoFixture and the
Selenium Remote Control Java API, we were able to hack together a custom Fitnesse fixture which reads surprisingly well.
First, you'll need to set up Selenium. I'm going to be writing a tutorial on it soon, but basically just download the Selenium Remote Control, unzip it, and start up the server. With the server running, you can write Java code which will make calls to the server and interact with the browser.
Now, onto our tests. We wanted to give our customers the ability to write tests like:
|The user navigates to the URL|http://www.google.com|
|The page has the title|Google|
|The page has an element named|q|
|The page has an element named|btnG|
|The user Types|Cory Foy|in the field named|q|
|The user clicks on the button named|btnG|
|The user closes the browser|This is the wiki-syntax from Fitnesse, and something our customers are familiar with writing. One of the nice things about the DoFixture in Fitnesse is that it knows how to convert these to java method calls. For example, this:
|The user navigates to the URL|http://www.google.com|gets mapped to:
public boolean TheUserNavigatesToTheUrl(String url) {}I've put the Fitnesse fixture
up for download. You'll need to compile it and put it on the classpath, along with the Selenium java client jar. To use it, you'll have to make sure that the SeleniumRunner is the first table in your test, and then initialize it using the Selenium properties. Ideally, you could just move this up to a SetUp method, so your user wouldn't see it.
|!-com.cornetdesign.fitnesse.SeleniumRunner-!|
|Set server to|localhost|and port to|4444|and browser to|*firefox|and domain to|http://www.google.com|The above puts the Fitnesse test into Flow mode, and then initializes the Selenium runner to point at localhost:4444 using the firefox browser, and having the URLs go against the domain google.com.
I'm going to be doing some more work with this, so feedback is welcome. I hope to get a good Selenium tutorial up soon.