Monday, 6 July 2009

nFocus Axe's Selenium

I've been working on getting Selenium to work with Axe for a couple of weeks now and I am pretty happy with the results so far, so I thought that I would share with you this practical walkthrough of how to get the two to talk together. Firstly, it is fair to note the versions that I have been running with, Axe : version, Selenium RC : version 1.0.1, Java : version 6 update 14

To start with, you are going to have to download and install all these tools. In order to get Selenium RC up and running, you are going to need to download and install Java, like I said, I'm using version 6 update 14, typing:

"java -version"

in a command prompt reveals :

Once you have Java and Selenium RC installed (you only need to unzip Selenium into your desired location), then you need to fire up the Java server, I created a little batch file containing the command "java -jar selenium-server.jar" and saved it in my

"C:\Program Files\Selenium\selenium-remote-control-1.0.1\selenium-server-1.0.1"

directory calling it "StartServer.bat". Finally I created a shortcut to this on my desktop and a simple double click will start the Selenium server running on the default port of 4444.

Now you will need to get Axe ready to deal with Selenium, firstly, we are going to need to edit the AxeConfig.xml file in the Axe program directory, we need to add a "tool" entry for Selenium, in the file, you will find an xml snippit file "AxeConfigSnippit.xml", you can insert this into your "AxeConfig.xml" file. The first thing to note about this tool entry is that it handles some of the actions performed while using the "New Project Wizard" like copying template files into the new project and some of the actions responsible for building and running the tests in Selenium (the <build> and <run> sections). You will notice that in the build/postbuildarguments, I have used a number of parameters like:


These are so that the ThoughtWorks dll's are referenced during the compilation and copied over to the scripts directory where the final Axe tests are built to. In order for this to work, you are going to need to copy the ThoughtWorks dll's (where they exist will depend on where you installed/unzipped Selenium RC) into the Axe program files directory. For me that looks like :

copy "C:\Program Files\Selenium\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\ThoughtWorks.Selenium.Core.dll" "C:\Program Files\Odin Technology\Axe"
copy "C:\Program Files\Selenium\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\ThoughtWorks.Selenium.IntegrationTests.dll" "C:\Program Files\Odin Technology\Axe"
copy "C:\Program Files\Selenium\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\ThoughtWorks.Selenium.UnitTests.dll" "C:\Program Files\Odin Technology\Axe"

I copied them here just to make the process of building and compiling easier.

The rest of the files that are included in the zip file are as follows :

C:\IntegrationFiles\samples\OdinPortal\Config\Selenium.BuildConfig.xml C:\IntegrationFiles\samples\OdinPortal\Config\SeleniumChrome.RunConfig.xml C:\IntegrationFiles\samples\OdinPortal\Config\SeleniumFireFox.RunConfig.xml

With the exception of the AxeConfigSnippit.xml file, all of the other files should be copied into their counterpart Axe (Program Files) directories e.g. :

copy "C:\IntegrationFiles\ActionMap\Selenium.ActionMap.xml" "C:\Program Files\Odin Technology\Axe\ActionMap"

Note also that you will have to create the "Selenium" directory as this will not currently exist:

C:\Program Files\Odin Technology\Axe\Templates\Selenium

With all this in place, you should be able to fire up the OdinPortal sample and kick off a few tests in the different browsers (assuming you have all of them installed).

Next week we will be putting together a tutorial on how to create a new Axe-Selenium project to run some tests against google.

The files to support this entry can be downloaded here....

1 comment:

JohnQ said...

Thanks, Dandino - this is really useful