We use automated tests to test the functionality of our web application. To make assertions in test cases less complex and more flexible, we consider introducing "TestIDs", that is, identifiers in HTML markup that help test files find and verify elements on the page. In addition, these test identifiers will allow more specific integration tests, which are currently not possible due to limited data on the pages.
However, here's what makes us shy:
- entering test identifiers means changing testing for testing
- security - we will disclose identifiers of objects of the internal domain and other information that otherwise would not be visible on the page
- - depending on how we put TestIDs in the markup, we are likely to violate the intended semantic use of the element or attribute (for example, the attributes "id" or "class", other html elements, etc.).
- Interference - TestID may affect application code
- performance - TestIDs are optional markup (for the user) and increase page size (only significant on large pages).
Limiting TestID to test / host HTML does not seem like a good idea, because we obviously want to test the code that will be used in the production process, and we don’t want our test / intermediate environment to behave differently. In fact, we are currently running parts of our test suites against a live system after release.
Do you think TestID is a good idea, and if so, how would you put them in the markup?
Some markup examples to demonstrate what I'm talking about:
<tr id="testid-carrot-id-188271">
<td class="color">green</td>
<td class="size">doesn't matter</td>
</tr>
source
share