adityasrinivasb Absent Member.
Absent Member.

Nine webelements identified instead of three



I am trying to identify webelements under a tree control using dynamic descriptive programming. The tree control here is an ExtJs Tree and we named it as ExtTree in the custom webadd-in. The webelements I am looking for are 13 digit numbers


My code is like this


Set oDesc = Description.Create


oDesc("micclass").Value = "WebElement"

oDesc("outerText").Value  = "\d{13}"

oDesc("outerText").RegularExpression = True


Set colDesc = Browser(x).Page(x).Extree(x).ChildObjects(oDesc)

Msgbox colDesc.Count


There are only three 13 digit numbers under the Exttree. But I get the count as 9. I used to a loop to check what is the outertext of those 9 elements and each element is counted thrice. So 3x3 =9. I get the count as 9.


Can somebody tell me what could be the problem? Currently I don't have the add-in developer who can help me fix this. I am curious to know if it a simple fix which I can do it myself.






1 Reply
Contributor.. JonWallace Contributor..

Re: Nine webelements identified instead of three

ExtJs builds quite a complicated structure of nested objects to render controls correctly in the browser.

Whilst there may only be three 13-digit-number objects you are trying to identify, you are probably also matching the parents of those objects.


<div ...>

    <div ...>

        <div class="specialClass">XYZ</div>


So in the structure above, finding div objects with innertext=XYZ will find all three objects.


The solution is to add an extra property that is unique to the element you want e.g. in this case the class (or you may need to use an index).


For more specific help, I'd need to see the relevant HTML.


Hope this helps



EDIT: Just noticed that you are using 'outerText' and not 'innerText', but I think my reply is still true.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.