In my test automation practice I always use a gui mapping strategy that reduces a maintenance effort.
So for example, if I need to identify the "Google Search" button (www.google.com), its XPAth will be
//input[@name='q']
rather than/html/body/center/form/table/tbody/tr/td[2]/input[3]
It's clear that in the second case
a little change in a page structure could break my test.
But maybe I'm missing something? Maybe if a document structure changes I should know about this and some of my tests should fail?
What do you think? What best-practice you will recommend?
If the element has an id that is used by scripting/css, we use that ID in testing. Otherwise we actively instrument our HTML for testing. By this I mean we can add an id just for testing to avoid any ambiguity. We usually give it a prefix to indicate this, ie. id="ftGoogleButton". This is so the people who work with the HTML only will understand that there is automated testing associated with the element. This convention is practical because they will normally only look in css/js for references to a given id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With