When you call a method of an object, TestComplete pauses the script execution until the execution of the called method is over (that is, the script is paused until the method returns). Using the
CallObjectMethodAsync method you can call application methods without pausing the script. This is useful if the method displays a modal window or dialog and you need to simulate user actions in this dialog (see Testing Modal Windows for more information).
You can also use this method to obtain a property’s value asynchronously (that is, you can use the method to perform asynchrounous calls to the property’s
Runner.CallObjectMethodAsync(Obj, MethodName, Param1, Param2, ..., ParamN)
|Obj||[in]||Required||The object whose method will be called|
The method is applied to the following object:
The method has the following parameters:
Specifies the object whose method will be called.
The name of the desired object method or property.
Param1, Param2, ... ParamN
Specifies the method parameters (if any). If you obtain the value of an indexed property, these parameters specify the index values.
CallObjectMethodAsync returns the
CallObjectMethodAsyncResult object that contains methods and properties allowing you to pause the script execution until the called method returns and providing access to method results.
CallObjectMethodAsync was added to simplify testing of modal windows and dialog boxes displayed by script routines or by methods that reside in Open Applications. See Testing Modal Windows for complete information.
It is not recommended to use this method to perform asynchronous calls to methods provided by TestComplete (that is, to methods that are provided by TestComplete but not by the application under test).
This method cannot be used to call methods of custom objects you create in your tests.
The following example demonstrates how you can use the
Runner.CallObjectMethodAsync method to display a modal window and perform testing actions over it.
def Test(): # Launches the tested application TestedApp = TestedApps.ModalSamples TestedApp.Run() Form = Aliases.SampleApp.Form # Calls the method that displays a modal form Result = Runner.CallObjectMethodAsync(Form, "ShowModal") # Performs actions over the modal form ModalForm = Aliases.SampleApp.ModalForm # ... # Closes the modal form ModalForm.Close() # Waits for the method completion Result.WaitForCompletion(2000) # ... TestedApp.Close()