Using the datadriven user-extension

Problem

There are several reasons for implementing datadriven testing. Imagine we have to test a telecom application, where we need unique phone numbers for every test. Or we have to test an insurance application, where we need unique policy numbers for every test. Or we have to test a banking application, where we need unique account numbers for every test cycle. For those reasons it could be extremely useful to populate the test with testdata from an external file. This can be done with the datadriven user-extension.

Prerequisites

We have to make the flow-control, include and datadriven user-extention available in Selenium IDE by loading the file into the IDE. The user-extensions can be downloaded from the following location: http://wiki.openqa.org/display/SEL/datadriven

Solution

The first thing we need to do is creating an XML file with testdata, which can be used in the tests. The testdata in the XML file is written as a key/value structure and will look like this: 


<testdata>
    <test key1="value1" key2="value2"/>
</testdata>
1
2
3
<testdata>
    <test key1="value1" key2="value2"/>
</testdata>

Once we have the XML with testdata, we can build or modify our tests. We have to load the XML file and walk through the testdata rows. For each row we have to execute the test. The script will look like this:

Command Target Value
loadTestData    
While !testdata.EOF()  
NextTestData    
//Script within the while-loop
endWhile    

What has been done

The user-extensions are loaded into the core of Selenium. The script will load an XML file from a preferred location and execute the script for every single line of testdata in the XML. We can call the keys from the test script itself, like this ${key1} and ${key2}

Using the datadriven user-extension
0 votes, 0.00 avg. rating (0% score)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>