How could QTP recognize the Web-element

qtp

I would like to get information about a web-element. This web-element is always present on the page. But QTP can't recognize, because there is a lot of web-elements with the same class. By default QTP used to recognize this web-element by it's InnerText property, but in the last build InnerText became changing dynamically. And number of the web-elements of the required class is changing from build to build.
Do you know, how could I help QTP recognize this object? I've tried to add x and y absolute and relative coordinates, but it didn't work.

Best Answer

Identifying elements by location is very brittle and should be avoided when possible.

Your question does not contain enough information in order to give a specific answer but here is how one achieves objects identification in the general case:

You have to find a combination of properties that make the description unique and robust. If this is hard to do you can use the following advanced object identification techniques.

  1. By default QTP has all web elements nested directly under the Page or Frame, but you can nest an object under any other web element. If your element is contained within another element which you can identify drag and drop it in the object repository under said container and then the description only has to be unique in regards to the container's other descendant elements
  2. Assuming you're using QTP 11 (or later) you can use visual relations identification. This can be very helpful in identifying objects (see documentation for more information).
  3. If all else fails you can use an ordinal identifier, if 3 elements match the description and the element you're looking for is always the second you can add this information in the ordinal identifier section of the object repository.
Related Topic