While testing an application, you may need to obtain data stored in its controls and objects to use this information in your tests. You may also need to modify some application data (for instance, text of an edit box control) from your tests. To get and set values of object properties from your keyword tests, use the following keyword test operations:
-
Call Object Method operation
-
Run Code Snippet operation
-
On-Screen Action operation
After you configure an operation to get the value of a certain property, the operation will return this value. To use the operation’s result, specify the Last Operation Result value type for one of the parameters of the subsequent operation. For detailed information, see Checking Operation Result.
Using the Call Object Method Operation
Use this operation to obtain or set the value of a certain property of the specified object. Note that this operation lets you operate not only with onscreen objects, but also with objects provided by TestComplete (Log
or Regions
, for instance). For detailed information, see the operation's description.
To configure the operation, do the following:
-
Add the Call Object Method operation to your keyword test. This will invoke the wizard.
-
Specify the object whose property value you want to get or set. To select a window or control object, press Select Object and then choose the desired window or control in the ensuing Select Object dialog. After you specify the desired object, press Next.
-
Select the needed property from the list of available methods and properties. If you need to get the property value, select the
PropertyName [Get]
property. If you need to change the property value, select thePropertyName [Set]
property. After you select the needed property, press Next. -
If the specified property has parameters, specify them on the next page of the wizard.
-
Press Finish to finish configuring the operation.
Using the Run Code Snippet Operation
The Run Code Snippet operation executes the specified script statement from your test. That is, you can specify a single-line script statement that will get or set the value of a certain property. For detailed information, see the operation's description.
To configure the operation, do the following:
-
Add the Run Code Snippet operation to your keyword test. This will invoke the wizard.
-
Type the code line that will get the needed object property. To add a window or control object to the code expression, press Select Object and then choose the desired window or control in the ensuing Select Object dialog. For a list of available object properties, explore the object in the Object Browser.
-
Press OK to finish editing the operation.
Note: |
In VBScript projects, the Run Code Snippet operation treats the equals sign (=) as a comparison operator by default. To treat it as an assignment operator, put the assignment code into the VBScript Execute("Log.Enabled = False") |
Actually, these two operations are similar. The difference is that the Call Object Method operation lets you specify operation parameters using special dialogs, which makes the editing easier (for instance, you may select the desired property from the list of available object properties). However, you may find it easier to specify some expressions with the Run Code Snippet operation than setting operation parameters in the dialogs.
Using the On-Screen Action Operation
This operation lets you get and set property values of onscreen objects. For detailed information, see the operation's description.
To configure the operation, do the following:
-
Add the On-Screen Action operation to your keyword test. This will invoke the wizard.
-
Specify the object whose property value you want to get or set and press Next.
-
Select the needed property from the list of available methods and properties. If you need to get the property value, select the
PropertyName [Get]
property. If you need to change the property value, select thePropertyName [Set]
property. After selecting the needed property, press Next. -
If the specified property has parameters, specify them on the next page of the wizard.
-
Press Finish to finish configuring the operation.