If you've been reading the blog posts by the Elastic Path QA team, you already know that we use Selenium-RC to automate storefront testing and Squish for automated Commerce Manager client testing. Selenium Remote Control (Selenium-RC) is an amazing testing tool, but it only works for web applications running in the browser. Squish is also a great tool, but it only works with desktop applications, like the CM client. For some of our test cases, we need to make changes in the CM client and then verify the changes in the storefront web application. In the past, we had to test this manually, which was time-consuming.
Now, we've come up with a way to fully automate this and generate a complete report with the test results. Basically, the strategy is to use a Squish script to invoke Selenium-RC, which then runs our Selenium scripts. This has saved us a lot of time. I'll explain how it works.
If you want to try this yourself, you need the following software on your test machine:
- Java 1.4 or later
- Ant 1.7.0 or later
- Firefox 2.0 or later
- Selenium IDE (for creating test suites and test cases)
- Selenium RC (for running the tests)
- Squish for Java
Selenium IDE and Selenium server can both be downloaded from the Selenium download page.
Also, make sure that Firefox is not remembering passwords; in Firefox,select Tools -> Options -> Security and uncheck the Remember password for sites option.
And if you are using self-signed certificate, a dialog appears when you open EP's account page to confirm that you want to access it. This will break the automated test script, so you need to go to the My Account page in Firefox, accept the certificate, and then close the browser. Next time the page opens (when you run the automated test), the dialog will not appear.
Creating your Selenium test project
- Use Selenium IDE to create a Selenium suite and test cases.
- Create a folder named epautotest. Inside this folder, create a lib folder and a tests folder.
- Copy build.xml to the epautotest folder. The build.xml file is the Ant build script, which includes all information Ant needs to run our Selenium tests. You can edit this file to suit your environment. For example, set the testDomain property to the URL of your storefront.

- Copy user-extension.js, summary.xsl, Tidy.jar and selenium-server.jar to the lib folder.
- user-extension.js contains functions that extend the base Selenium functionality.
- summary.xsl is the test report template file.
- Tidy.jar is the open source library we use to generate the test report.
- selenium-server.jar is the library required to execute the Selenium tests. (You can get it from your Selenium RC installation.)
- Copy the Selenium test suite and test cases to the tests folder.
- Copy your Firefox profile folder (found in C:\Documents and Settings\<your_username>\Application Data\Mozilla\Firefox\Profiles) to the epautotest folder.
- Modify the build.xml file to point to the copy of your Firefox profile folder.
Running the Selenium tests
Now, you want to make sure that your Selenium tests run. To run the tests, simply type ant in the epautotest folder. When the tests are finished, a summary can be found in the file test-results\test-summary.html. The folders under test-results mirror the folders under the tests folder and each individual test suite's report can be found under it's relevent folder. Note that the previous test run's results can be found in the test-results.old folder.
Using Squish to run Selenium tests
Next, you need to create a batch file that can be invoked by your Squish scripts. This will run the Ant build script that runs your Selenium tests.
- Create a batch file in the Squish scripts folder named ep.bat. The contents should look something like this: ant -f c:\epautotest\build.xml
- In your Squish scripts, when you want to run the Selenium tests, add a command to invoke the batch file. This command might look like this:
var i = OS.system("c:\\epautotest\\ep.bat");
We can get the test reports in the c:\epautotest\test-results folder.
With this fairly simple integration between Selenium and Squish, we've been able to extend automated test coverage and save valuable QA time. If you'd like to see how this works, give it a try. You can use the files I've attached to this post. Let me know if you have questions!