Thursday, December 16, 2010

FitNesse with Selenium using Generic Fixture

Selenium-RC is the solution for tests that need more than simple browser actions and linear execution. Selenium-RC uses the full power of programming languages to create more complex tests like reading and writing files, querying a database, and emailing test results.
You’ll want to use Selenium-RC whenever your test requires logic not supported by Selenium-IDE. What logic could this be? For example, Selenium-IDE does not directly support


  • condition statements
  • iteration
  • logging and reporting of test results
  • error handling, particularly unexpected errors
  • database testing
  • test case grouping
  • re-execution of failed tests
  • test case dependency
  • screenshot capture of test failures

FitNesse with Selenium using Generic Fixture

You can download latest fitnesse.jar file from http://fitnesse.org/FitNesseDevelopment.DownLoad 
And then Create a folder under C:/Program Files/Fitnesse/
Copy fitnesse.jar file and paste into C:/Program Files/Fitnesse/    folder.
Double click on " fitnesse.jar " file it will install itself.

Download Selenium Remote Control

Selenium-RC can be downloaded from http://seleniumhq.org/download/
Unzip the downloaded Selenium-RC into C:/Porgram Files/Selenium/ folder.


Create a start script for Selenium and Fitnesse


Open text file and Copy the following code into it and save the text file as Selenium.vbs

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
   Next
End Function


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



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

Wscript.Quit




Open text file and Copy the following code into it and save the text file as Fitnesse.vbs


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
   Next
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

Wscript.Quit




Download and Install Generic Fixture


You must have FitNesse framework installed on your computer and FitNesse server must be running on the computer where Generic Fixture is being installed.

You can download 

Download the jar file genericfixture.jar containing full source code and compiled classes from Generic Fixture Sourceforge Site. Included classes have been generated using Sun’s JDK 1.5 Java compiler. Should you need to build Generic Fixture with any other JVM then make sure to put fitnesse.jar and fitlibrary.jar (provided in all the Fitnesse releases) in your CLASSPATH.

Install the Generic Fixture

Save genericfixture.jar somewhere on your computer where FitNesse server is running. Then simply add genericfixture.jar in your classpath on FitNesse Wiki. eg:
!path /path/to/download/dir/genericfixture.jar

Run startup script


Run the startup scripts Selenium.vbs and Fitnesse.vbs files which will start the both the servers.


Now you are about to run your own fitnesse scripts.......



No comments:

Post a Comment