In a nutshell
The getFileName() function returns the file name of a specified input file as a text, including its extension. It is useful in test cases for validating file naming conventions or confirming that the expected file has been retrieved or downloaded.
1. Overview
The getFileName() function returns the name of the specified input file, including its extension. This is useful for validating file naming conventions or confirming that the expected file has been retrieved or downloaded.
2. Syntax
<variable> = files.<filename>.getfilename();
Parameter | Description |
<variable> | Defines the response returned by the getFileName() function. It represents the name of the file as a string. |
<fileObject> | 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
- FileName = files.ztest.getfilename();
- //perform file function action on a downloaded file
- assertFileDownload("downloadedfile.txt",5,errorhandling.STOP_ON_ERROR);
- DownloadFile = File("downloadedfile.txt");
- FileName = DownloadFile.getfilename();
- //to fetch file using invoke URL and perform file functions
- File = invokeURL[
- url : "<downloadURL>"
- type:GET
- ];
- FileName = File.getfilename();