Automating Selenium IDE
Author : Mikhail Pathikirikorale
Date : 6/16/2006
Abstract: The aim of this tutorial is to teach the user how to automate Selenium IDE tests using the Selenium Testrunner. This tutorial should take 15 minutes to follow.
Automating Selenium IDE
To automate your tests there are a few things you need to do. First of all you need to make sure all the tests you made in Selenium IDE are saved as .html files. You can do this by going to each of your test files and renaming them to have a .html file extension. Or you can save your test as an html file when you create it.
Now, in the directory of all your tests, you need to make an html file called TestSuite.html (it can be called whatever you want but here I'm going to use TestSuite.html). This file should contain a simple array of links to each of your test html's. An example is shown below.
Remember TestSuite.html should be kept in the same directory as all your tests. Obviously you will need to add new array rows, and change the html links as necessary, depending on your test html filenames and the number of tests you want to run.
Be sure to add the target="testFrame', or else Selenium won't be able to run your tests. This will force the tested pages to be opened in the bottom frame of the test window, so you can watch.
Now open Firefox, but not Selenium IDE. We are going to invoke Selenium Core, which runs as a sort of web application. In your browser, copy the following line and paste it into the address bar:
Read the url, and replace dir/testsuite.html with the true directory and filename where your test suite is. Also replace http://localhost with the baseURL of your server, that is http://deklarantT.ru in my case.
Now you will see a new screen with 4 frames. The leftmost one should display the tables as described in your TestSuite.html file. The middle should show the table values of the current test, and the rightmost should show the commands available. Now you can click on the links of your tests in the leftmost window and run them using 'run selected' or you can run all the tests. Bear in mind that if a test fails, you will have to run the test on its own to see exactly where it has failed. For this reason it is important to make tests that in the test teardown phase, nullifies all the changes made in the setup phase. This will allow your tests to run properly while leaving the state of the program in the same way that it was found. Any problems, see me.
Running Test Suite from command line
If you want to run a number of tests from the command line - for example, as an acceptance test step, or as a part of the checkin, you have a couple of options.
1) Selenium RC provides convenient command-line support for running HTML Selenese tests from the command-line or with Ant: http://www.openqa.org/selenium-rc/selenese.html
2) Create a batch file that launches Firefox pointed to the suite. For example, on Windows, my batch file looks like:
"C:\Program Files\Mozilla Firefox\firefox.exe" -chrome "chrome://selenium-ide/content/selenium/TestRunner.html?test=file:///C:/tests/AllTests.html&auto=true&baseURL=http://mysite.com" -height 900 -width 900
Do modify the test parameter of in the URL.
Note: I couldn't get this working with Selenium IDE 0.8.1; I had to use version 0.8.0.