Writing Script Extensions - Specifics

Applies to TestComplete 15.70, last modified on December 17, 2024

Creating TestComplete extensions by scripting has some specifics when compared to common scripting and scripting for test automation. These specifics are listed below:

  • Unlike TestComplete projects, references between script files in a script extension package are not allowed. Called routines must be located in the same script file as the caller ones.

  • Not all TestComplete project objects are available to script extensions. For example, the TestedApps and KeywordTests objects are not available to script extensions. However, there are workarounds that let you resolve this issue. For example, if you created a keyword test and you need to use it in script extensions, you can convert it to script and use the ensuing script. If you need to work with the tested application in your script extensions, you can use the WScript.Shell (or the similar WshShell) scripting object. You can find an example on our web site:

    Get an application’s exit code

    For a complete list of objects available to script extensions, see Objects Available to Script Extensions.

  • The VBScript’s MsgBox function raises an error when called from the script extension code. To display message boxes, use the various methods of the aqDlg object.

  • It is possible to use national characters in the script extension code and the description file. For example, you can display native-language messages with the aqDlg.MessageDlg method, or give your custom actions native-language names. However, in this case you must save the file containing national characters in the UTF-8 encoding.

  • To improve the test execution performance, TestComplete limits some functionality of native language-specific objects returned from script extension code. For example, for…in statements in JScript, C#Script or C++Script TestComplete scripts cannot iterate through properties of a native JScript object or through items of a native array returned from a script extension. Therefore, to avoid this problem, we recommend that you design your script extension so that objects or arrays returned from its code allow addressing their properties and array items by indexes if possible. After that, you can use a regular for loop to iterate through object properties or array items by their indexes instead of using a for…in loop.

  • If your design-time action performs actions against the TestComplete main window (for example, minimizes the window, changes the window size and position, and so on), an error will occur. This happens due to specifics of thread organization in TestComplete.

  • If you write script extensions in the case-sensitive JScript language, remember that its elements should be referred in the same case they are written. This feature applies to VBScript units since the VBScript engine will not distinguish the elements which share the same names even written in a different case. It also parses the script text before interpreting and saves names in their first written word form in the internal case insensitive storage.

    To avoid issues which can be caused by these features, do not use similar names for extension elements or script unit routines and variables. For more information and examples, see VBScript - Specifics of Usage.

See Also

Script Extensions
Creating Script Extensions

Highlight search results