Selenium Driven Development
From Clickframes
This document shows how to develop your Clickframes application by initially generating all the selenium tests and then making the tests work.
For the purpose of this document we will refer to an application developed with the seam plugin.
Contents |
Write the appspec.xml
First you need to write your application specification located at:
src/main/clickframes/appspec.xml
1. Write the techspec.xml to generate both application code and tests
The techspec is located at:
src/main/clickframes/techspec.xml
The following techspec generates seam code, selenium tests and browsable specs ("clips").
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<techspec xmlns="http://www.clickframes.org/techspec"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<package>com.myorg.demo</package>
<plugins>
<plugin class="seam" />
<plugin class="selenium" />
<plugin class="clips" />
</plugins>
</techspec>
2. Generate code
Now generate code from this techspec by running:
mvn clickframes:generate
3. Run the application
Run the application in glassfish.
mvn glassfish:run
Prepare tests in the target directory
The selenium plugin generates test suites for the entire application in the following directory
src/test/selenium/clickframes/
Many test suites are generated in nested directories. Each test suite is made of individual test cases, which are re-usable pieces of code, like functions. You can identify the test suites as files with names like "*suite.html". It can be pain navigating to individual suites and running them through your IDE.
The clickframes:prepare plugin will automatically scan all the test suites according to your criteria and put them in one master suite in the target directory.
For example, the command:
mvn clickframes:prepare-tests -Dclickframes.regex=pgregister.*verifyPositive
... finds all test suites for the page "register" where the test suites names contain the word "verifyPositive". This corresponds to all the tests which verify positive value for inputs on the page register.
The target suite is generated in:
target/clickframes/selenium/regex/tests/master-test-suite.html
Selenium Test Driven Development
You can load the prepared test suite in the selenium IDE and run it against your application. Fix the broken tests, regenerate tests and rerun them.
Suggested Schemes for Preparing tests
Test positive path first
Test positive inputs in page.
mvn clickframes:prepare-tests -Dclickframes.regex=pgregister.*verifyPositive
Test positive form submission If you page is called "register" and outcome is "accountCreated", then the following should create a suite for positive path.
mvn clickframes:prepare-tests -Dclickframes.regex=pgregister.*accountCreated.*verifyFormOutcome -o

