Error: XPath Value changes for different instances of same value on webpage



Hi Community,

I am trying to grab values of “Named Insured” from exact same location on a web based tool/App(This is actually a tool/App used for Policy management) for three different Insureds[ See screenshots for your ready reference]

Issue that I am facing: I am trying to copy the same value using a bot that I have designed. My bot basically grabs the value using “Xpath method”, but for some reason, the Xpath values are different for all the three values of “Insured Name” in different instances/webpages.

I am assuming that’s the reason why my bot is not able to grab these values and ends up with Errors when Named Insured values dynamically change on the web page.

Am I doing it the right way? Can anyone assist me in achieving this objective of mine -Thanks in advance!!

Need help with this asap please.

In the screen shot below, I have stored the XPath values of all three values(of Named Insureds) in a notepad.



Hi @Sharma_Nikhil,

The purpose of the “Web Element” or Xpath-based actions is to give you control over dynamic values, NOT IDs, and the IDs as shown above are different which could be the reason of the error. It seems as if the label/span control which is being used to display the Name Insured caption is dynamic and keep changing at the code level maybe. Firstly check the ID of label using inspect element and if that is dynamic you probably need to take a different approach.

Use the “Wait For Image” if you have any specific flag or caption that can be checked to distinguish different policies and set an appropriate flag based on that. Use conditional statement then to work with the associated xpath depending upon the particular flag status. You should also use “Error Handling” to implement the fall down logic and to avoid any error.

I’d say go with the xpath that has contains in it rather than absolute @id where possible (e.g. //span[contains(@id,‘lblNameInsured’)]).