Forum Discussion

TomDeleu's avatar
TomDeleu
Occasional Visitor
8 days ago

Best method to correct NameMapping/xpath after Object position changes?

Hi.

Some context first:

The app uses several buttons on a banner, stored in <div> elements. 
The Namemapping assigns these with xpath from left to right.
The question mark gets '//div[1]', the globe is '//div[2]' etc. to simplify.

 

 

One update later, the app has a new button put in front of the others in the banner. Now this button claims '//div[1]'.

 

 

My keyword tests don't notice this change at first and click the wrong button positions due to all of them shifting one place in the HTML. Nothing fails at first, because technically there's a button to click, just not the right one. Naturally, all of my test start failing soon after arriving on the wrong pages.

Changing every div index position in the Namemapping xpath seems like the obvious solution, but it becomes tedious when updates like these happen so often. I tried Self-Healing, but it doesn't always work.

Is there a way to automatically recognize and correct this?

Thanks in advance.

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I would use an attribute that has the title or name or something else for the icon rather than index. The name might change but likely not as often as the index and it is easy to replace as opposed to the task of changing all the index entries.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    XPath uses path expressions to select nodes in an XML document. If a new node is added in the middle, it ends up shifting all other nodes beneath it.

    If your xpath is referring to a parent object, it might be best to omit that, and see if TC is still able to identify the object.

    I've avoided using XPath because of this reason, as we have a lot of <div> used in our web app