Use the Run Code Snippet operation to execute a script statement or method call from your keyword test.
This operation is similar to the Run Script Routine operation. However, it lets you call script statements that are not a script routine. You typically use it when you need to call a method or property of an object that does not have a keyword test analogue and there is no need to create a script statement for this.
||The called script statement must be a single-lined statement.
If the executed script statement returns a value (for instance, if the statement is a method call and the method returns some value), then the operation returns this value. For information on how to obtain this value, see Checking Operation Result.
If the executed script statement does not return any value, the operation has no result value as well.
The dialog that TestComplete displays to specify the operation parameters contains the edit box in which you can enter the desired script statement. TestComplete displays this dialog when you add the operation to your keyword test. You can also add an object to this statement. The way you add it depends on the object's type:
- If the object is an on-screen window or control, then to specify it, you can click Select On-Screen Object and use the subsequent Select Object dialog to choose the desired window or control. See Selecting Objects for Keyword Test Operations.
- If the object is one of TestComplete runtime objects, then to specify it, you can click Select Object and use the subsequent Select Runtime Object dialog to choose the desired object's name.
- If the desired object's name is stored in a project suite, project or keyword test variable, then to specify it, you can click Select Variable and then use the subsequent Select Variable dialog to choose an existing variable or to create a new one.
To modify the parameters of the operation that was added earlier, simply double-click the operation row in the Keyword Test editor. TestComplete will invoke the same dialog that was shown when you added the operation to the test. Use this dialog to enter the desired script code.