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
-
Enable the update feature of the desired file:
-
Enable the Tools > Options > Engines > Stores > Update files option in TestComplete.
-
Select the Update check box of the desired file in the Stores > Files collection.
-
-
Command TestComplete to update the file from a test by using one of the following:
-
The
Files.Compare
method -
The
File.Check
method -
The
File.CheckPDFText
method
-
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:
For information on how to do this, see Updating File Checkpoints.