Reputation: 171
Developers has proposed a solution to add Test Name for all the elements in the Design Code and this test name can be used in automation to find elements, so that even when they change the design name or selector it will not impact automation.
<input test-name = *"test_uname"* id="username" type="text" required="required" maxlength="40" name="username"/>
Introducing test-name = test_uname
I need your suggestion and pros/Cons of this approach
Upvotes: 1
Views: 184
Reputation: 25714
In the example you posted, there is already an ID. Why not just use that? IDs on all the elements you care about would be the best. If your application autogenerates dynamic IDs, then some custom attribute like test-name
would be ideal. I would encourage you to name them something that makes sense, e.g. test-name="username"
for the username field. Make them human readable as much as possible. Also, you don't need to prepend each attribute with "test_", it's already in test-name
so that should be enough.
Upvotes: 0
Reputation: 46
Great solution by developers. By following these standards automation scripts can be more stable.
Suggestion : Don't use tag name while designing to make automation script to sustain even in design change.
e.g In your case following xpath should be formed
//*[@test-name = 'test_name']
In this case, even if html tag gets changed automation script will not get fail.
Upvotes: 1