How to structure Selenium tests with less maintenance

Here are few things to structure Selenium tests with easy to maintain, reliable automated tests.
Building your Selenium tests using the Page Object pattern
For more on Page Object model click here.
Map your controls in a single place
Your controls should be mapped into a single location, so that if control changes, you only need to change it in a single location. Having it in a single location allows you to make a one-line code change if a developer re-maps the controls.
Abstract the test automation tool where possible
There are usually three actions that are performed most of the times - InvokeSetvalue, and GetValue. Invoke will click a link or button, check or uncheck a checkbox etc. SetValue will put values into controls, like putting text into a text box. GetValue gets data from the controls, which is primarily used for verification.

Use regular expressions to map your control names
Using regular expressions lets you define the control in a way that the developer can move it anywhere on the page and your tests will still run.
Create test data objects to hold your test data
Creating additional tests in some cases can be as simple as using an existing test with different data.
Separate the test from the implementation
Separation of concerns is a key technical design principle that you should apply from your tests. The intent of the test case should be separated from the physical implementation that does the interaction with the page as much as possible.

No comments:

Post a Comment