I just started looking into Selenium as a way to automate some of my testing two days ago. Thanks to others posting about similar things, I’ve managed to create a data-driven web test using an XML file as the data source. Here’s how I did it:
2. Install the extensions in the Selenium IDE in the same order as listed above. Re-start the IDE after you specify all of the extensions.
3. Create an XML file. Here’s a small portion of mine:
<test nameText=”HELLO!!!!!&<>"'” addressText=”This is my address”/>
<test nameText=”Name” addressText=”Address Test Test”/>
XML does have limitations with special characters, so I had to change “&” to “&”, “<” to “<” etc. – see “Special Characters and XML Strings”
4. Create a test case in the IDE. The first command must load the test data. I had to play around with the “while” portion of my test case to ensure that the loop was functioning properly. Here’s some useful documentation from the OpenQA Wiki on the structure of the test case. This is my test case, which edits Account Name and Address in my web application. It then saves the changes, logs out, logs back in, and ensures that the name displayed on the home screen is the name that was just saved. It’s just a simple test, I plan to add a lot more to it.
And that’s it! At first, I kept getting errors in the IDE about the datadriven extension, but when I traced the code, I discovered that the real problem was with my XML file. Your XML file cannot have ANY errors in it (no matter how small) or else the test won’t work. If you get an error, check your XML file first!
Although I am happy to be able to easily create data driven tests, I’m already seeing the limitations of using XML as input. I’ve made it my goal for today to figure out how to use a SQL data source. Look for that as my next blog post!