Adding Files to the Files Collection

Applies to TestComplete 14.10, last modified on June 5, 2019

The Files collection of the Stores project item stores the files that you can use during application testing for comparison purposes.

You can add files to the Files collection in several ways:

Adding Files From the Files Editor

  1. Right-click the Stores | Files node in the Project Explorer panel and select Edit from the context menu. TestComplete will display the Files editor in the Workspace panel.
  2. Right-click somewhere within the editor and choose New Item from the context menu.
  3. Select the desired file using the subsequent Add File dialog.

Adding Files From the Project Explorer

  1. Right-click the Stores | Files node in the Project Explorer panel and select Add | New Item from the context menu.
  2. Choose the desired file from the ensuing Add File dialog.

Adding Files From Tests

To add files to the Files collection from your script or keyword tests, call the Add method of the Files object.

For instance, the code below adds the OrderList.txt file to the project’s Files collection:

JavaScript, JScript

if (!Files.Add("C:\\MyApplication\\OrdersList.txt", "OrdersList"))
  Log.Message(Files.LastError);

Python

if not Files.Add("C:\\MyApplication\\OrdersList.txt", "OrdersList"):
  Log.Message(Files.LastError)

VBScript

If Not Files.Add("C:\MyApplication\OrdersList.txt", "OrdersList") Then
  Log.Message(Files.LastError)
End If

DelphiScript

if not Files.Add('C:\MyApplication\OrdersList.txt', 'OrdersList') then
  Log.Message(Files.LastError);

C++Script, C#Script

if (!Files["Add"]("C:\\MyApplication\\OrdersList.txt", "OrdersList"))
  Log["Message"](Files["LastError"]);

See the Files Object topic for more information on working with files from your scripts.

To call the Files.Add method from your keyword test, use the Call Object Method, Run Code Snippet or Run Script Routine operation.

Remarks

When you add a file to the Files collection, TestComplete converts the name of the selected file to a name that is allowed in scripts. For example, the name 1.bat cannot be used in script code. This file name will be converted to the A_bat name, which is valid and can be used in your scripts.

See Also

About Files Collection
Files Object
About Files Editor
Modifying Stored Files

Highlight search results