In a nutshell
The getFileSize() function returns the size of a specified file in bytes. It is useful in test cases for validating that a file has been completely downloaded, meets expected size criteria, or for triggering conditional logic based on file size.
1. Overview
The getFileSize() function returns the size of the specified file in bytes. This is useful for validating if a file has been completely downloaded, meets expected size criteria, or to perform conditional logic based on file size.
2. Syntax
<variable> = files.<filename>.getfilesize();
Parameter | Description |
| Defines the response returned by the getFileSize() function. It represents the size of the file in bytes. |
| Specifies the file object to be accessed. This can be a file downloaded, invoked via URL, or loaded from saved files.
|
3. Example
- //perform file function action on a file saved locally
- FileSize = files.ztest.getfilesize();
- //perform file function action on a downloaded file
- assertFileDownload("downloadedfile.txt",5,errorhandling.STOP_ON_ERROR);
- DownloadFile = File("downloadedfile.txt");
- FileSize = DownloadFile.getfilesize();
- //to fetch file using invoke URL and perform file functions
- File = invokeURL[
- url : "<downloadURL>"
- type:GET
- ];
- FileSize = File.getfilesize();