Save File

The Save File block allows you to store files generated during test execution in a fixed location. This ensures that file-based output (such as logs, reports, or exports) can be reused, analyzed, or retrieved by other parts of the automation flow.

This block supports common formats like .txt, .csv, .json, .pdf, .xlsx, and .xml, and does not require a manual file path. Content is passed dynamically and saved in the Leapwork database and file system.

Example: A test case generates a JSON report containing API response data. Using the Save File block, this report is saved in a predefined storage location, allowing subsequent test cases to retrieve and analyze it.

When fully expanded, the following is an example of the Save File block with sample data:

image-20251112-145845.png

Note: The screenshot on this page uses the Elegance Design, introduced in 2025.3. If you are using an earlier version, your layout may look different.

Quick Start

  1. Drag Save File onto the canvas.

  2. Connect File Input to the output of a block that provides file content (e.g., a block that generates or returns a file).

  3. Run the flow when it’s ready.


Building block parameters

Parameters
  • Block header: The left green input connector in the header is used to trigger the block to execute and save the file. The right green output connector in the header is triggered once the file has been successfully saved. This allows subsequent blocks in the automation flow to continue execution only after the file is stored.
    The block title Save File, can be changed by double-clicking on it and typing a new title.

  • File Input: Receives the file content to be saved. Supports multiple formats: .txt, .csv, .json, .pdf, .xlsx, .xml. Content is passed from upstream blocks and saved automatically with a unique filename.

  • Not saved:Triggers if the file could not be saved (e.g., due to empty input, internal error, or storage failure). If triggered, the log message will state:
    "Cannot save the file. Please add content before saving."

  • Default timeout: Allows the use of the global timeout defined in the flow settings. If not selected, the block will default to a local timeout of 10 seconds.

  • Timeout:Specifies the maximum time allowed for saving the file. If this time is exceeded, the block will trigger Not saved.

Additional behavior

  • Successful execution
    When the Save File block completes successfully, the file is stored and the run log will display the message:
    "File {file name.ext} saved successfully."
    The filename is automatically generated to ensure uniqueness. This confirms that the file content was written and stored as expected.

  • Download option
    After execution, the saved file can be downloaded directly from the Keyframes panel by selecting the block and accessing the file under Media.
    The same download option is available in test reports for completed runs, making it easy to retrieve generated files even after execution has finished.

  • Storage path
    Files are saved automatically to the following default directory on the agent machine:
    C:\Program Files\Leapwork\Assets\AutomationRunMedia\SomeFolder\SomeFolder\Files\
    The exact subfolders depend on the run context, but Leapwork manages the full path internally. No manual path configuration is required.

Resources

Topic

Description

Flows FAQ

Common questions about creating, running, and managing flows in Leapwork.

Flows Troubleshooting

Guidelines and solutions for identifying and fixing issues that occur when building or running flows in Leapwork.