Description
Assigning and obtaining property values are performed through the get
and set
property’s methods. When you assign a value to a property, TestComplete pauses the script execution until the execution of the called set
method is over (that is, the script is paused until the method returns). Using the SetObjectPropertyAsync
method you can assign values to application methods asynchronously, that is, without pausing the script. This is useful if the property’s set
method displays a modal window or dialog and you need to simulate user actions in this dialog (see Testing Modal Windows for more information).
Declaration
Runner.SetObjectPropertyAsync(Obj, PropertyName, Param1, Param2, ..., ParamN, Value)
Obj | [in] | Required | Object | |
PropertyName | [in] | Required | String | |
Param1 | [in] | Optional | Variant | |
Param2 | [in] | Optional | Variant | ... |
ParamN | [in] | Optional | Variant | |
Value | [in] | Required | Variant | |
Result | A CallObjectMethodAsyncResult object |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
Obj
Specifies the object’s method that you want to call.
PropertyName
The name of the desired object property.
Param1, Param2, ... ParamN
These parameters are optional. They are used if you are working with an indexed property. In this case, they specify the index values.
Value
Specifies the value to be assigned to the property.
Result Value
SetObjectPropertyAsync
returns the CallObjectMethodAsyncResult
object that contains methods and properties allowing you to pause the script execution until the property assignment is over.
Remarks
SetObjectPropertyAsync
was added to simplify testing of modal windows and dialog boxes displayed by script routines or by properties that reside in Open Applications. See Testing Modal Windows for more information.
We recommend that you use this method to perform asynchronous calls to the properties provided by TestComplete (that is, to the properties that are provided by TestComplete but not by the application under test).
Example
The following example demonstrates how you can use the Runner.SetObjectPropertyAsync
method to perform testing actions over the modal window invoked when an object’s property is modified.
JavaScript, JScript
{
var TestedApp, Form, ModalForm, Param, ResObj;
// Launches the tested application
TestedApp = TestedApps.ModalSamples;
TestedApp.Run();
Form = Aliases.SampleApp.Form;
Param = Form.Param1;
// Sets a value to the property
ResObj = Runner.SetObjectPropertyAsync(Param, "Text", "new text");
// Performs actions over the invoked modal form
ModalForm = Aliases.SampleApp.ModalForm;
…
// Closes the modal form
ModalForm.Close();
ResObj.WaitForCompletion(2000);
// Simulates actions after the modal form is closed
…
TestedApp.Close();
}
Python
def Test():
# Launches the tested application
TestedApp = TestedApps.ModalSamples
TestedApp.Run()
Form = Aliases.SampleApp.Form
Param = Form.Param1
# Sets a value to the property
ResObj = Runner.SetObjectPropertyAsync(Param, "Text", "new text")
# Performs actions over the invoked modal form
ModalForm = Aliases.SampleApp.ModalForm
# ...
# Closes the modal form
ModalForm.Close()
ResObj.WaitForCompletion(2000)
# Simulates actions after the modal form is closed
# ...
TestedApp.Close()
VBScript
Dim TestedApp, Form, ModalForm, Param, ResObj
' Launches the tested application
Set TestedApp = TestedApps.ModalSamples
TestedApp.Run
Set Form = Aliases.SampleApp.Form
Set Param = Form.Param1
' Sets a value to the property
Set ResObj = Runner.SetObjectPropertyAsync(Param, "Text", "new text")
' Performs actions over the invoked modal form
Set ModalForm = Aliases.SampleApp.ModalForm
…
' Closes the modal form
ModalForm.Close
ResObj.WaitForCompletion(2000)
' Simulates actions after the modal form is closed
…
TestedApp.Close
End Sub
DelphiScript
var TestedApp, Form, ModalForm, Param, ResObj;
begin
// Launches the tested application
TestedApp := TestedApps.ModalSamples;
TestedApp.Run;
Form := Aliases.SampleApp.Form;
Param := Form.Param1;
// Sets a value to the property
ResObj := Runner.SetObjectPropertyAsync(Param, 'Text', 'new text');
// Performs actions over the invoked modal form
ModalForm := Aliases.SampleApp.ModalForm;
…
// Closes the modal form
ModalForm.Close;
ResObj.WaitForCompletion(2000);
// Simulates actions after the modal form is closed
…
TestedApp.Close;
end;
C++Script, C#Script
{
var TestedApp, Form, ModalForm, Param, ResObj;
// Launches the tested application
TestedApp = TestedApps["ModalSamples"];
TestedApp["Run"]();
Form = Aliases["SampleApp"]["Form"];
Param = Form["Param1"];
// Sets a value to the property
ResObj = Runner["SetObjectPropertyAsync"](Param, "Text", "new text");
// Performs actions over the invoked modal form
ModalForm = Aliases["SampleApp"]["ModalForm"];
…
// Closes the modal form
ModalForm["Close"]();
ResObj["WaitForCompletion"](2000);
// Simulates actions after the modal form is closed
…
TestedApp["Close"]();
}
See Also
Calling Methods Asynchronously
Testing Modal Windows
Runner.CallMethod Method
Runner.CallObjectMethodAsync Method