Forum Discussion

Lambis's avatar
Lambis
New Contributor
13 years ago

OR operand in FindChild method

Hello there,



I am using FindChild and Find methods in most of my scripts in the project I am currently working on and I want to know if there is a way to set in the PropValues array a condition under the OR operand. Since I know Find* methods of TC are working only in the AND philosophy. For example, a script I am using is looking for an OK button in the whole page and searches like this:




var PropArray = new Array ("SlFullClassName", "SlObjectName");


PropArray = Array ("SlFullClassName", "SlObjectName");

var ValuesArray = new Array ("System.Windows.Controls.Button", "OKButton");


 


var Item = Parent.FindChild(PropArray, ValuesArray, 100);


The application I am testing has different implementations of the OK button. Hence I would like to include these different implentations in a single FindChild statement, in order not to call FindChild many times in a script and increase its execution time. I would like to search the objects that are Buttons and their "SlObjectName" property has the value OKButton OR btnOK. Is there any way to include this OR conditions into a single FindChild statement?



I am new in the forum and I don't know whether the question I am raisin here has been answered before.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Within the FindChild method, no, as far as I know there is not.



    HOWEVER... if you use NameMapping and employ the conditional mode, then yes, you can. (see http://smartbear.com/support/viewarticle/12852/)



    This requires you to do some more work up front in mapping out your components, but it is possible to do this with NameMapping.



    If you prefer not to, what you would need to do is employ two "FindChild" statements and then call the "Exists" method off the resulting objects and do a check to determine which one is the one that is actually used.