File Operations

The folder TBox Automation Tools->File Operations in the Standard subset contains the following Modules:

TBox Image Compare

The Module TBox Image Compare allows you to verify pixel-accurate image files in the following formats: BMP, JPG, and GIF.

It has the following attributes:

ModuleAttribute

Description

FirstImageFilePath

Path and file name of the first image file.

SecondImageFile

Path and file name of the image file that you want to compare to the first image file.

In this example, you compare the image file logo_new.jpg to the image file logo.jpg.

Compare two image files

TBox File Existence

This Module allows you to verify whether a file exists in a specific directory.

The Module TBox File Existence has the following attributes:

ModuleAttribute

Description

Directory

Path to the file.

File

Name of the file whose existence you want to verify. You can use ActionModes Verify or WaitOn.

You can verify the name as follows:

  • To verify that a specified file does not exist, put the negation symbol ! in front of the file name.

  • To verify if multiple files exist, use the wildcard character * to replace one or more characters in the file name.

This example verifies whether the file test01.xml exists in the directory D:\.

Verify the existence of a file

The screenshot below shows how to verify that the file doesn't exist in the directory D:\.:

Verify that a file doesn't exist

TBox File Compare

This Module allows you to compare the content of two files and optionally see the results in a merged file.

After execution, you can view the result in the Loginfo column of the ExecutionEntry.

The Module TBox File Compare has the following ModuleAttributes:

ModuleAttribute

Description

FirstFilePath

Full path to the first file, including the file name and extension.

SecondFilePath

Full path to the second file, including the file name and extension.

DiffReportOutputFolder

If you want to save a merged file to compare the differences, specify a path.

You can verify the changes in the merged file as follows:

  • If the second file has additional content, the TBox File Compare Module highlights this in green.

  • If the second file has missing content, the TBox File Compare Module highlights this in red.

  • If contents are the same, the TBox File Compare Module won't make any changes.

The TestStep in this example performs the following actions:

  • Compares the file data.xml to the file dataNew.xml.

  • Saves the results as a merged file to C:\Sales\reports.

Compare two files

TBox Copy File

Use this Module to copy and paste files within the Microsoft Windows® file system. If you want to paste a file to a different directory, this directory must already exist at run-time.

The Module TBox File Operations has the following attributes:

ModuleAttribute

Description

Source

Path and file name of the file that you want to copy.

Target Directory

Directory to which you want to paste the file.

Target Filename

If you want to rename the file, specify the new file name.

Overwrite

By default, Tricentis Test Automation for SAP doesn't overwrite existing files. If you want to overwrite the existing file, set the value to True.

The TestStep in this example performs the following actions:

  • Copies the file report_new.xml from the directory C:\Reports to C:\Sales Reports.

  • Renames the file to report.xml.

  • Overwrites the existing file in the target directory.

Copy and paste a file to another directory

TBox Delete File

This Module removes a file from a specific directory.

The Module TBox Delete File has the following ModuleAttributes:

ModuleAttribute

Description

Directory

Path to the file that you want to delete.

File

Name of the file that you want to delete. To delete multiple files, use the wildcard character * to replace zero or more characters in the file name.

If the system can't locate the file or any files matching a file name that contains a wildcard, the execution result shows the following description: The file <file name> does not exist.

The test result is positive.

In this example, you delete the file test.xml from the directory C:\Temp.

Delete a file

TBox Read/Create File

This Module allows you to perform the following actions:

  • Create a text file.

  • Write text to a text file.

  • Verify or buffer text in the file.

  • Wait on text in the text file.

The Module TBox Read/Create File has the following ModuleAttributes:

ModuleAttribute

Description

Directory

Path of the file that you want to create or read.

File

Name of the file, including the file extension.

Text

Text that you want to write, verify, buffer, or wait on.

Use ActionMode Input, Verify, Buffer, or WaitOn, respectively.

Encoding

.NET character encoding of the file that you want to create. This is optional.

You can choose the following encoding options: UTF-8, UTF-16 and ISO-8859-15.

Overwrite

If you want to overwrite the target file, set the value to True and use ActionMode Input.

Add Byte Order Mark

Specify whether you want to add a byte order mark (BOM) to the preamble of your file. This is optional and only applies to files with UTF-8 or UTF-16 encoding.

By default, Tricentis Test Automation for SAP automatically adds a BOM to files with UTF-16 encoding. To add a BOM, note the following:

  • If you want to add a BOM to a file encoded with UTF-8, use the value True.

  • If you don't want Tricentis Test Automation for SAP to add a BOM to a file encoded with UTF-16, use the value False.

The TestStep in this example performs the following actions:

  • Creates a new text file named test.txt in the directory C:\Temp .

  • Adds the file content A nice text..

  • Uses character encoding UTF-8.

  • Overwrites the existing file in the target directory.

  • Adds a byte order mark.

Create a new file

This example verifies whether the file test.txt in the directory C:\Temp contains the text This is text in the file.

Verify text in a file

TBox Append File

This Module appends the Text ModuleAttribute to the defined file.

If you define a file that doesn't yet exist, TBox creates it.

The Module TBox Append File has the following ModuleAttributes:

ModuleAttribute

Description

Filepath

The full file path in which the file is located.

Text

Text that should be appended.

End with Newline

Set the value to True if you want the text to be appended with Newline at the end. This is optional.

In this example, you append text to a file in the directory C:\Temp.

Append a file

TBox Move/Rename File

This Module allows you to move and rename a file. If you want to move the file to a different directory, this directory must already exist at run-time.

The Module TBox Move/Rename File has the following ModuleAttributes:

ModuleAttribute

Description

Existing Path

Path, file name, and extension of the file that you want to move or rename.

New Path

New path and/or file name. Note the following:

  • To only rename the file, enter its current path and a new file name.

  • To only move the file, enter a new path and the current file name.

The TestStep in this example performs the following actions:

  • Renames the file report_scan.jpg to scan.jpg.

  • Moves the file to C:\Temp\reports.

Move and rename a file