Forum Discussion

jeetendra_mitta's avatar
jeetendra_mitta
Occasional Contributor
12 years ago

Problem regarding using wild card in property

I need to identify the object in which its content type starts with "F" following with alphabets and ends with numeric value. For that I can use either "*" or "?". But using these wild cards it will be match for more than one objects having any content type. In QTP I can easily use with pattern- "F[a-z].*[0-9]". but in TestComplete, there is any way to use this pattern to get unique object.

7 Replies

  • jeetendra_mitta's avatar
    jeetendra_mitta
    Occasional Contributor
    But when user wants to use the descriptive programeing then, only "?", "*" can be used. I want to describe the object then use the find or find all methods.
  • jeetendra_mitta's avatar
    jeetendra_mitta
    Occasional Contributor
    Thanks for your reply. But we are using any windows application. Can you please suggests what should I use to correct object identification.
  • Hi Jeetendra,

     


    In this case, only the * and ? wildcards can be used. We have a suggestion to add the possibility of using XPath expressions in Windows apps - I've increased its rating based on your request.


     


    Right now, you can do the following:


     - obtain the unique parent of the desired object;


     - search through all children with the specified type, say text boxes, of the parent object:




     textBoxes = parent.FindAllChildren("WndClass", "Edit", 2);




     - iterate through all children to find the one that will match your XPath expression:




    textBoxes = (new VBArray(textBoxes)).toArray();


    if (textBoxes.length > 0)


      {


        var regEx = /F[a-z].*[0-9]/g;


        for (i = 0; i < textBoxes.length; i++)


          str = textBoxes.wText;


          Matches = str.match(regEx);


          if  (Matches.length!=0)


            desiredObject = textBoxes;


      }




     


    Refer to the "FindAllChildren Method" and "Using Regular Expressions in Scripts" articles for more information.


     

  • jeetendra_mitta's avatar
    jeetendra_mitta
    Occasional Contributor
    Thanks a lot for your valuable effort, we are using vbscript. Can you please provide us code in vbscript.