![]() |
This method is obsolete. See the Remarks section below. |
Description
Use this method to call a script routine specified by its unit name and routine name.
Declaration
Runner.CallMethod(ComplexName, Param1, Param2, ..., ParamN)
| ComplexName | [in] | Required | String | |
| Param1 | [in] | Optional | Variant | |
| Param2 | [in] | Optional | Variant | ... |
| ParamN | [in] | Optional | Variant | |
| Result | Variant | |||
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
ComplexName
Specifies the name of the script routine to be executed. The name should be specified in the unit_name.routine_name format. Both unit_name and routine_name are required.
Param1, Param2, ... ParamN
Specify parameters passed to the routine.
Result Value
If the specified routine is a function, CallMethod returns its value, otherwise, CallMethod returns a varEmpty Variant variable. You can check it using the aqObject.GetVarType method.
Remarks
-
The
Runner.CallMethodmethod is obsolete and it is supported for backward compatibility only. You can call routines directly by their names without using theRunner.CallMethodmethod. If the desired routine is declared in another unit, add theUSEUNITstatement to the current unit to include a reference to the unit that contains the routine declaration. For more information on this, see Calling Routines and Variables Declared in Another Unit from GUI. -
If you use DelphiScript, to call a routine that returns a value, you can use the
Evaluatefunction instead of theRunner.CallMethodmethod. -
If you call a routine declared in a different unit, there is no need to specify
unit_namein theUSEUNIT(oruses) clauses of the current unit. -
To call an object’s method by its name, use the
aqObject.CallMethodmethod. -
It is impossible to call a routine with the
Runner.CallMethodmethod from anOnStopTestevent handler (this event is generated when the test run is stopped, for instance, by calling theRunner.StoporRunner.Haltmethod or by clicking the
Stop button on the Test Engine toolbar). All routine calls performed by Runner.CallMethodfromOnStopTestevent handlers are ignored and the called functions are not executed.
For JScript, C++Script and C#Script users:
-
If a function called by
Runner.CallMethodreturns an array, the array’s elements cannot be iterated in afor…inloop. Due to some specifics of TestComplete subsystems, such a loop is not executed during the script execution and no iteration is performed. For example:JScript
var Arr = Runner.CallMethod("Unit1.GetArray");
// The loop will not be executed
for(var i in Arr)
{
Log.Message(Arr[i]);
}C++Script, C#Script
var Arr = Runner["CallMethod"]("Unit1.GetArray");
// The loop will not be executed
for(var i in Arr)
{
Log["Message"](Arr[i]);
}To avoid this problem, you can use one of the following workarounds:
-
Use the
USEUNITstatement to include a reference to the unit containing the called function and directly call the function from the current unit (without usingRunner.CallMethod). -
Create an ActiveX array object (for instance, a
Scripting.Dictionaryobject or some other) in the called function and return this object instead of a native array. -
Use a
forloop instead offor…into iterate elements of the array returned by the function.
-
- If you use the method to call routines declared in another unit, TestComplete may handle exceptions that occur while executing these routines incorrectly. For more information, see the Specifics of Usage Common for All Languages help topic.
See Also
Calling Routines and Variables Declared in Another Unit from GUI
Runner.CallObjectMethodAsync Method
aqObject.CallMethod Method

