Updating Stored Files

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

The Stores > Files collection contains files that you can use in tests for file comparison and verification (see About File Checkpoints and PDF Checkpoints).

In some cases, you may need to update a file stored in the collection. For example, you may need to update a stored file so that a file checkpoint passes.

You can do this in one of the following ways:

Note: To make minor changes to a file’s contents, you can do this manually. For information on how to do this, see Modifying Stored Files.

From Tests

  1. Enable the update feature of the desired file:

  2. Command TestComplete to update the file from a test by using one of the following:

When file updating is enabled, the methods will replace the contents of the stored file with the contents of the specified file instead of comparing them.

The following code demonstrates how to use the Files.Compare method to update a stored file:

JavaScript, JScript

var StoredFile = Files.NameByFileName("C:\\Work\\OrdersList.txt");
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
Files.Compare (StoredFile, "C:\\Work\\OrdersList_new.txt");

Python

StoredFile = Files.NameByFileName("C:\\Work\\OrdersList.txt")
# Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
Files.Compare (StoredFile, "C:\\Work\\OrdersList_new.txt")

VBScript

StoredFile = Files.NameByFileName("C:\Work\OrdersList.txt")
' Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
Files.Compare StoredFile, "C:\Work\OrdersList_new.txt"

DelphiScript

var StoredFile : String;

StoredFile := Files.NameByFileName('C:\Work\OrdersList.txt');
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
Files.Compare (StoredFile, 'C:\Work\OrdersList_new.txt');

C++Script, C#Script

var StoredFile = Files["NameByFileName"]("C:\\Work\\OrdersList.txt");
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
Files["Compare"](StoredFile, "C:\\Work\\OrdersList_new.txt");

The following code demonstrates how to use the File.Check method to update a stored file:

JavaScript, JScript

var StoredFile = Files.NameByFileName("C:\\Work\\OrdersList.txt");
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
StoredFile.Check ("C:\\Work\\OrdersList_new.txt");

Python

StoredFile = Files.NameByFileName("C:\\Work\\OrdersList.txt")
# Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
StoredFile.Check ("C:\\Work\\OrdersList_new.txt")

VBScript

StoredFile = Files.NameByFileName("C:\Work\OrdersList.txt")
' Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
StoredFile.Check ("C:\Work\OrdersList_new.txt")

DelphiScript

var StoredFile : String;

StoredFile := Files.NameByFileName('C:\Work\OrdersList.txt');
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
StoredFile.Check ('C:\Work\OrdersList_new.txt');

C++Script, C#Script

var StoredFile = Files["NameByFileName"]("C:\\Work\\OrdersList.txt");
// Replaces the contents of the OrdersList.txt file with the contents of the OrdersList_new.txt file
StoredFiles["Check"]("C:\\Work\\OrdersList_new.txt");

To update files form keyword tests, use the File Checkpoint operation or the PDF Checkpoint operation, or call the Files.Compare or File.Check method by using the Call Object Method, Run Code Snippet or Run Script Routine operation.

From Logs

You can also update stored files from the test log:

Updating stores files from TestComplete test log

Click the image to enlarge it.

For information on how to do this, see Updating File Checkpoints.

See Also

Files
Files Editor
Modifying Stored Files

Highlight search results