Forum Discussion

jmarkman's avatar
jmarkman
Occasional Contributor
6 years ago
Solved

Regex/Wildcards in FindChild method

One of the buttons in my company's program changes between "Show Items" and "Hide Items" when clicked - it's a toggle. I'd like to run some automation with this button, and I've been trying to use the FindChild method rather than a direct mapping since elements around it (not the button itself) are prone to change. In the remarks section of the FindChild method's documentation, it says I can supply a TC regular expression. However, when I provide it, it's unable to find the element. When I provide the full name of the property I want to use instead of regex, it's able to find the element:

 

FindChild(new Array("className", "ObjectLabel"), new Array("btn btn-xs ng-binding", "Show Items"), 4);

Does FindChild support the regex method in the first place? Can I do something like 

"* Items"

instead?

  • Yes, you can do the wildcard like you indicated... but, as for reg-ex... in the documentation.

     

    "

    Regular expressions should start with "regexp:", for example:

    obj = parent.Find("PropName", "regexp:gr[ae]y", 5)"

2 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    You could still use name mapping with a conditional setup for the button, and extended find to skip the dynamic parent elements. 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Yes, you can do the wildcard like you indicated... but, as for reg-ex... in the documentation.

     

    "

    Regular expressions should start with "regexp:", for example:

    obj = parent.Find("PropName", "regexp:gr[ae]y", 5)"