Forum Discussion

svruss's avatar
svruss
Occasional Contributor
14 years ago

Regular expression in FindChild method

Hello,



Todaty, my question is about correct syntax on regular expression in FindChild method. I have follow code part:



 selectElement = page.FindChild( new Array( "ObjectType", "innerText" ), new Array( "Panel", "*"+element+"$"+"*" ),100);



where variable element is part of multi row string. I try to catch element and end row after it, but my current C#script code is wrong. Can help me?



Best Regards,

Svetoslav

4 Replies


  • Hi Svetoslav,





    The FindChild method does not work with regular expressions, but you can use wildcards. Please let me know whether this works for you:



     selectElement = page.FindChild( new Array( "ObjectType", "innerText" ), new Array( "Panel", "*"+element+"\r\n*" ),100);

  • svruss's avatar
    svruss
    Occasional Contributor
    I check it, but unfortunately it doesn't work. With \r\n it go on main panel in tested web-page and set for selectElement main panel on page,  with only \n - nothing happened, selectElement in watch list return object, but without additional parameters (object is not expandble). Web-page is main panel with few childs - expandble panels. What happened if I create additional variable and there create expression with element and then use this variable in FindChild?

  • Hi Svetoslav,





    In this case, you need to put more identification properties to differentiate the main panel and the panel you are searching for. Currently, when you use '\r\n', several objects satisfy the search condition, and TestComplete returns the first one. You can check this using the FindAllChildren method.
  • svruss's avatar
    svruss
    Occasional Contributor
    Thank you, I arrive at a same conclusion when check parameters on main panel. Page was returned for redesign and I hope that next week all will be Ok.