Find Object Operation

Applies to TestComplete 15.40, last modified on July 05, 2022

Description

The Find Object operation searches for an object by its property values, and if this object is found, calls its method or property.

Operation Result

The operation returns the same value, which the called method or property returns. If the object is not found, the operation returns null (in JavaScript, JScript, C#Script, C++Script), None (in Python), Nothing (in VBScript) or nil (in DelphiScript).

Scripting Analogue

The operation is a keyword test analogue to searching for an object with the Find method and then calling a method or property of the found object.

Child Operations

The operation cannot have child operations.

Operation Parameters

The operation uses the following parameters:

  • The object to which the desired object belongs.

  • The set of property values that will be used for the search.

  • The method (or property) of the found object to be called.

  • The method’s (or property’s) parameters, if any.

When you add the operation to your keyword test, TestComplete displays a wizard that lets you specify all of these parameters. To modify parameters of an operation that is already added to the test, you can use special dialogs and in-place editors provided by the Keyword Test editor. These dialogs and in-place editors are analogues to the wizard’s pages.

Specifying Parameters When Adding the Operation

The wizard, that TestComplete displays when you are adding the operation to your test, contains the following pages:

Select Object

On this page, you specify the object that contains the sought-for object. The operation will search for the desired object in the specified object, its children, and then continue down the selected object’s hierarchy. The Object search strategy property of your project controls whether the operation uses depth-first or breadth-first search.

To specify the object, you can select it on screen, or, if the object is mapped, choose the object’s mapped name or alias. For detailed information, see Selecting Objects for Keyword Test Operations.

Specify Search Criteria

On this page you can specify property values which the sought-for object should have. The operation will enumerate objects belonging to all levels of the specified object and compare their properties against the specified values. Once it finds the object, in which the specified properties contain the specified values, the operation stops the search.

Notes:

  • The specified collection of property values should uniquely identify the desired object, because the operation works with the first found object that matches the search criteria. This object may differ from the desired object.

  • We do not recommend using the VisibleOnScreen property in search criteria. It can significantly decrease your test performance because it may take some time for TestComplete to get this property’s value, and TestComplete will have to get the value for every object it checks during the search.

To append a property to the search criterion:

  • Press Add. This will add a new item to the list.

  • Click within the Property Name column and type the desired property name.

    Press Enter to confirm the change, or Esc to cancel it.

  • Click within the Value cell and type the desired property value.

    To specify string values with variable parts, you can use wildcards or regular expressions:

    • Wildcards: asterisk (*) corresponds to a string of any length (including an empty string), the question mark (?) corresponds to any single character (including none).

    • Regular expressions should be in the “regexp:pattern“ format. For the supported regular expression syntax, see here. Native regular expressions of the scripting languages are not supported.

    All string values and regular expressions are case-insensitive.

    Press Enter to confirm the change, or Esc to cancel it.

You can specify both properties provided by TestComplete and (if the tested application is an Open Application) properties defined in the application’s code.

To remove a property from the search condition:

  • Select the desired item in the list.

  • Click Remove.

Specify Method or Property

On this page you can choose the method or property of the found object to be called. The operation will call this method (or property) to perform an action on the found object or obtain information about it. For detailed information about methods and properties, see the description of the object. If the method or property is provided by TestComplete, you can find the description in the TestComplete help.

Operation Parameters

On this page you specify the parameters of the method (or property) that will be called by the operation. For information on the parameters, see the method (or property) description. If the method or property is provided by TestComplete, you can find the description by searching for the method (or property) name in the TestComplete help.

For more information on setting the values on the page, see Specifying Operation Parameters.

Modifying Parameters

After adding the operation to the test, you can modify the operation parameters with the same wizard that you used to add the operation. To invoke the wizard, simply double-click the operation’s row in the Keyword Test editor.

To modify parameters of the operation, you can also use the in-place editors and dialogs provided by the Keyword Test editor.

To specify another parent and search criteria:

  • Select the operation in the test.

  • Click within the Item cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Click the ellipsis button within the in-place editor. This will invoke the Select Object page of the wizard that was displayed when you added the operation to the test.

  • In the wizard, specify the desired parent object and click Next to activate the Specify Search Criteria page.

  • On this page of the wizard, specify the property values that are used as the search criteria.

  • Click Finish to close the wizard.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

To choose another method or property to be called by the operation:

  • Select the operation in the test.

  • Click within the Operation cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Select the desired property or method from the drop-down list.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

To specify the method or property parameters:

  • Select the operation in the test.

  • Click within the Value cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Click the ellipsis button of the in-place editor. This will invoke the Operation Parameters dialog, in which you can specify the parameters. For detailed information on the parameters, see description of the method or property, to which the parameters belong.

  • Click OK in the dialog to save the changes.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

See Also

Test Actions Category
Specifying Operation Parameters
Selecting Objects for Keyword Test Operations
Checking Operation Result

Highlight search results