Forum Discussion

emailvision_Sup's avatar
emailvision_Sup
Occasional Contributor
14 years ago

ignore tab and space in a property for FindChild

Hello,



I would like to know if there's a way to use wildcards/regexp in order to make a findFindchild on a property. 

My aim is to find out some objects based on their properties but with a name like "share" I would like to find for example a link even if the property that I'm checking contains tab or space characters before/after "share".



For example I would like to get with myProcess.FindChild("innerText","Share",10) an object even if it's innerText property is "   Share" or " Share    " ...etc.



I've looked wildcards/regExp but I don't know how to use it for that purpose.



If someone have an idea :).



Thanks for your Help

Nicolas.

4 Replies

  • mijex71989's avatar
    mijex71989
    Occasional Contributor
    Hello,



    You can use asterisk (*) or question mark (?) wildcards. The asterisk corresponds to the string of any length, the question mark - to any single character:





    myProcess.FindChild("innerText","*Share*",10)

  • emailvision_Sup's avatar
    emailvision_Sup
    Occasional Contributor

    Hello,



    Thanks for the answer. Unfortunately, even if it's working, It's possible that I have two objects including same word so '*' wildcard is too large.



    I.e.: I can have "save" and "save you profile" on two different objects and the "*save*" will find one or the other depending on their position. That's why I'm looking for something like "ignore space/tab" to put before and after in order to limit the "risk".



    Thanks,

    Nicolas.

  • Hi Nicolas,





    If so, you need to use a custom regular expression to find the object you need. Here is the approach you can use:

    1. Use the FindAllChildren method to find all objects which match some primary criteria (for example, have the "*save*" string).

    2. Enumerate the returned objects.

    3. For each object, check whether the corresponding property matches a specific regular expression. To learn how to do this, please see the "Using Regular Expressions in Scripts" help topic (http://www.automatedqa.com/support/viewarticle/12096/).