A script is a procedure or function in one of the supported scripting languages.
Scripts are grouped into unit files, and each project may use as many units as needed. In a TestComplete project, all the units belong to the Script project item. When you create a new project, TestComplete automatically creates the Script project item with one unit in it.
|Note:||Since a unit name can be used in scripts, it should be a valid script identifier, and it should not coincide with the names of existing program objects.|
A typical script usually contains:
Objects that provide scripting interface to the process of your tested application and its UI elements.
Methods of those objects that simulate user actions over the tested applications and its UI elements.
There are two ways to create a script:
The easiest way is to record a script test.
You can also write a script test manually in the Code Editor in TestComplete.
To modify scripts, open them in the Code Editor. To do this, right-click a unit that contains a script in the Project Explorer and choose Edit from the context menu. TestComplete will open the Code Editor with the unit code.
When you edit a script unit, TestComplete automatically creates a backup copy of the unit file. The copy resides in the same folder as the unit file resides. The copy has the original unit file name and the .bak extension. Using this copy you can restore the unit code as it was before editing.
You can call scripts from other scripts by their name. If you want to call a script from another unit, you must import it first. You can also import units of other projects. See Calling Routines.
When you create a project, you select a scripting language for this project:
Support for these languages is built into TestComplete, and does not require additional modules or configuration. All languages are restricted to variables of the OleVariant-compatible type, and cannot use pointers. Types specified in variable or function declarations are ignored.
TestComplete is equally oriented on each of the supported scripting languages. However, each of the languages has its pros and cons that may or may not match your specific requirements. To decide which language to choose, read the following:
For complete information on the supported scripting languages, use the links below:
|C#Script||Writing C# Scripts|
|C++Script||Writing C++ Scripts|
You can run scripts:
As your project’s test item specified either by the script name and unit or by tags.
From the Project Explorer.
From the Code Editor.
From other tests.
From the command line.
To learn more, see Run Scripts.
Before running any script, TestComplete checks all script units for syntax errors. The script will not be run if syntax errors are found.
TestComplete script files can have either ANSI, UTF-8 or Unicode (UTF-16) format. Some source control systems treat Unicode files as binary and thus do not let you perform some operations over such files, for example, compare or merge. Please refer to the documentation on your source control system to learn how you can work with Unicode files.
To solve the problem, you can also change the character encoding format used in your project for script files. For more information on this, see Units Encoding.