Jump Start FitNesse with Selenium using Generic Fixture

Download FitNesse

Go to http://fitnesse.org/FitNesseDevelopment.DownLoad and download the the latest fitnesse.jar. Create a directory c:\program files\fitnesse\. Copy the downloaded fitnesse.jar into directory c:\program files\fitnesse. fitnesse.jar is an executable jar file so just double click this file and it will install itself.

Download Selenium Remote Control (Selenium RC)

Go to http://selenium-rc.openqa.org/download.jsp and download the latest version (1.0.3 at the time of writing this page). Unpack the zip into c:\program files\selenium\ directory. Current version for Selenium-RC is 1.0.3 and these instructions are written assuming you are using this version.

Create a smart start script

Copy and paste following script into a file called run.vbs under the directory “C:\Program Files\selenium\selenium-server-1.0.3”. This script will start both FitNesse servers and Selenium remote control servers on their default ports 8000 and 4444 respectively. This script will ONLY start these processes if these processes are not running, so this script can be safely run any time.

PS: Please note that this script is starting Selenium in an experimental Proxy Injection Mode which lets you run your web test across multiple domains. If you don’t want to use this feature feel free to change this start script.

Function IsProcessRunning( strServer, strProcess )
   Dim Process, strObject
   IsProcessRunning = False
   strObject   = "winmgmts://" & strServer
   For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
       If UCase( Process.name ) = UCase( strProcess ) Then
           IsProcessRunning = True
           Exit Function
       End If
End Function

sServer = "."      ' "." for local machine
Set objShell = WScript.CreateObject("WScript.Shell")
Set objEnv = objShell.Environment("Process")

FitNesse = "java -cp fitnesse.jar fitnesse.FitNesse -p 8000"
If( IsProcessRunning( sServer, FitNesse ) = False ) Then
   objshell.CurrentDirectory  = "C:\program files\fitnesse"
   f = objshell.Run  ( FitNesse, 6, false )
End If

Selenium = "java -jar selenium-server.jar -browserSessionReuse -proxyInjectionMode"
If( IsProcessRunning( sServer, Selenium ) = False ) Then
   objshell.CurrentDirectory = _
"C:\program files\selenium\selenium-server-1.0.3"
   result = objshell.Run  ( Selenium, 5, true )
End If


Download and Install Generic Fixture

Just follow simple instructions at this page or just download genericfixture.jar from here and drop it into “C:\Program Files\fitnesse” directory.
Copy selenium-java-client-driver.jar from “C:\program files\selenium\selenium-remote-control-1.0.3\selenium-java-client-driver-1.0.3” to “C:\program files\fitnesse” directory.

Run startup script

Using Windows explorer go to the directory “C:\Program Files\selenium\selenium-remote-control-1.0.3\selenium-server-1.0.3” and double click on the run.vbs. This will start 2 Java process in 2 separate command windows with Selenium window in normal and FitNesse window in minimized state.

Create a page on FitNesse for Google Web Test using Generic Fixture

  1. Open your browser and goto the URL http://localhost:8000/FrontPage. Look for the Edit button on the left hand navigation column. If Edit button is not present then goto the URL http://localhost:8000/FrontPage?properties and select the “Edit” check box and click on Save Properties. Now click on Edit button and once on the Edit Page add a new line at the end of all the text already there and save your changes.
    |[[Web Test Suites][FitNesse.SuiteWebTests]]|FitNesse's suite of Web Tests|
  2. Now on the Front Page it will display a text like “Web Test Suites?” with ? as hyper link. Click on ? link.
  3. Once in the Edit Page copy paste following text into text area and save your changes:
    !*> Class Path & Global Defines
    !path selenium-java-client-driver.jar
    !path genericfixture.jar
    !define IE {*piiexplore}
    !define FF {*pifirefox}
    !define sel {selenium=}
    !define ds {com.thoughtworks.selenium.DefaultSelenium}
    !define host {localhost}
    !define port {4444}
    !define COLLAPSE_SETUP {true}
    !define COLLAPSE_TEARDOWN {true}
  4. You will notice 3 ? links on the page. Now lets create each and every missing page.
  5. Click on the ? link next to SuiteWebTests.SetUp text and on the “Edit Page” text area copy-paste following code an save your changes.
    !| DSL Adapter |
    | user types | % | into | % | field | type | {2}, {1} |
    | user starts the browser | start | |
    | users opens the URL | % | open | {1} |
    | page has the title | getTitle | |
    | user sees the text on the page | % | isTextPresent | {1} |
    | page has an element named | % | isElementPresent | {1} |
    | page loads in less than | % | seconds | waitForPageToLoad | {1}000 |
    | page has URL | getLocation | |
    | user clicks on submit button | click | //button[@type='submit'] |
    | user clicks on the link named | % | click | link={1} |
    | user clicks on the button named | % | clickAt | {1},"" |
    | get text from element named | % | getText | xpath=id('{1}') |
    | user stops the browser | stop | |
    | add a key-value with key | % | and value | % | put | {1}, {2} |
    | get value for the key | % | get | {1} |
    | show | toString | |
    !|Generic Fixture|${sel}${ds}|${host}|${port}|${FF}|http://${host}|
    | user starts the browser |
  6. Go back to the page: http://localhost:8000/FitNesse.SuiteWebTests
  7. Click on the ? link next to SuiteWebTests.TearDown text and on the “Edit Page” text area copy-paste following code an save your changes.
    !| Generic Fixture | ${sel} |
    | user stops the browser |
  8. Again go back to the page: http://localhost:8000/FitNesse.SuiteWebTests
  9. Now click on ? link next to SuiteWebTests.GoogleTest text and on the “Edit Page” text area copy-paste following code an save your changes.
    !define q {fitnesse generic fixture}
    !| Generic Fixture | ${sel} |
    | users opens the URL | http://www.google.com |
    | page has the title | | Google |
    | page has an element named | q | | true |
    | page has an element named | btnG | | true |
    | user types | ${q} | into | q | field |
    | user clicks on the button named | btnG |
    | page loads in less than | 5 | seconds |
    | page has the title | | ${q} - Google Search |
    | user clicks on the link named | Next |
    | page loads in less than | 5 | seconds |
    | user clicks on the link named | Next |
    | page loads in less than | 5 | seconds |
    | user sees the text on the page | Results 21 - 30 | | true |
  10. After saving your changes click on Properties button from the left hand navigation menu and click on check box left to Test property and save your changes. Now you should see Test button on the top of the lest navigation menu.

Execute your Google Web Test Page on FitNesse using Selenium

Just click on the Test click on this page: http://localhost:8000/FitNesse.SuiteWebTests.GoogleTest and watch the magic of web test being run. Test will open a new Firefox browser and go to http://www.google.com and search Google with query text “fitnesse generic fixture”
Upon completion of test you should see this on the top of the results page:

Assertions: 5 right, 0 wrong, 0 ignored, 0 exceptions

Optional but Recommended Installations

You are all set to to write your test tables in FitNesse.

However if you are doing web testing using Selenium, there are two very handy add-ons for Firefox that will be extremely useful for writing web tests:

  1. XPath Checker: Download it from https://addons.mozilla.org/en-US/firefox/addon/1095
  2. Selenium IDE: Download it from http://selenium-ide.openqa.org/download.jsp

27 thoughts on “Jump Start FitNesse with Selenium using Generic Fixture

  1. Hi Vasu,

    Can you please give little more info like stack trace or else try running equivalent Java code directly without FitNesse to see if there is some compatibility issue with latest Selenium, FitNesse versions as this post was published about 4 years back.


  2. vasu says:

    Hi anubhava
    I am unable to run selenium fitnessee combination it’s saying java.lang.null pointer exception

  3. Hi Eric,

    Thanks for your comments but unfortunately I don’t have Windows 7 in my possession at present to try and see problem myself. I am not a vb script expert either, I just made that script be learning some quick tutorials. Sorry I won’t be of much help here 😦


  4. Eric says:

    Hey Anubhava,

    Having some issues getting the run.vbs script to cooperate. I’m running windows 7 the 64-bit version so the files in question are stored under program files (x86). I went into the script and updated those paths myself to try and resolve the issue but when I attempt to run the script it still fatals complaining that it doesn’t know where the files are. Any ideas? I’d appreciate any help I could get :\.

    – Eric

  5. Brian says:

    Thanks Anubhava,

    I have started to follow step 3 and all is starting to make a bit more sense,

    Kind Regards


  6. Hi Brian,

    Unfortunately there is no automated utility to convert recorded Selenium IDE test code to FitNesse. But this is what I do for my personal testing:

    1. Record tests in Selenium IDE
    2. Convert tests to Java
    3. Look at the Selenium method calls in generate Java code and put them to Fitnesse Wiki.

    I think it won’t be too difficult to automate step # 3 above in a script but I just could not get time to that.


  7. Brian says:

    Hi Anubhava,

    I am totally new to FitNesse & Selenium but have a requirement to do some web testing and was pointed in the direction of using the two aforementioned products.

    I have successfully followed the steps above and have started to write my own basic tests that execute without errors.

    The question I have is around using Selenium IDE to record tests and play them back through FitNesse.

    I have installed IDE in Firefox and have recorded some basic tests however I do not have a valid FitNesse Format that will convert my recorded tests into something FitNesse can recognize.

    Is the format option for IDE something that is readily available or does it have to be written to use your genericfixture.jar ?

    Kind Regards


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s