Ask a Question

Regex/Wildcards in FindChild method

SOLVED
jmarkman
Occasional Contributor

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?

2 REPLIES 2
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)"


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
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. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
cancel
Showing results for 
Search instead for 
Did you mean: