Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI mapping strategy in test automation

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?

like image 331
legesh Avatar asked Jan 23 '23 20:01

legesh


1 Answers

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.

like image 154
krosenvold Avatar answered Jan 31 '23 01:01

krosenvold