Using ColdFusion within Selenium
Selenium only cares the output is in its simple table structure. Please refer to Sebastien Lachance's post about Structure of an html test and James Netherton's post about Selenium suites . I use the Firefox IDE to initially create scripts and save as a cfm file. Then add the ColdFusion sweetness.
Here is a simple use of ColdFusion within a Selenium test script to create a random email address. This would be useful when needing unique email addresses for testing a create new user process.
<cfset r = Randomize(5)>
<cfset email = "#r#@test.com">
<tr>
<td>type</td>
<td>emailAddress</td>
<td><cfoutput>#email#</cfoutput></td>
</tr>
Generating dynamic test scripts are easy. Here is an example of looping through all the options of a select statement with a query and verifying after submitting.
<cfquery name="selectOptions" datasource="DS">
select select_id, selectName from selectTable
</cfquery>
<!— loop through select options—>
<cfloop query="selectOptions">
<tr>
<td>select</td>
<td>Select_ID</td>
<td>value=#selectOptions.select_ID#</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>button</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>select_ID</td>
<td>#selectOptions.select_ID#</td>
</tr>
<!— more checks, actions, and then return back to form —>
</cfloop>




Posted under: 

