Skip to content

FileHandler function

This function is used to handle certain request like watch a folder for certain time, verify the particular text in a file, copy a file file from source to destination, remove a file from certain folder and many other operations related to files.

Select SET command from the Action drop-down, leave the Screen name blank, write a variable name in the Element key, click on form, you will see form will open, select function from the drop down then select FILEHANDLER function and select key value from cmd field. The file handler function shown below:

Watch Command

Watch command under FILEHANDLER function is used to watch a file of given type in a particular folder and returns the path of the file.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as Watch, provide target folder, extension, prefix, timeout, orderby and track.

Here, folder is path of the folder to watch extension is the file extension which we are trying to watch like txt, pdf or CSV prefix is any string before the file name timeout is the timeout value in seconds order by is way of filtering the files and you can use date, size or name track is either ascending or descending.

After completing this step, the test step will look as below:

Tabular view : 

Card view :

Copy Command

Copy command under FILEHANDLER function is used to copy one file to another folder i.e.. from source to destination.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as copy, provide source file, destination folder and select if you want to overwrite existing file or not.

Tabular view : 

Card view :

If the file is copied successfully in the destination folder, it will return true else it will return false in a variable defined in Element Key.

Delete Command

Delete command under FILEHANDLER function is used to delete a particular file from a specified location.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as delete and provide file path in file.

Tabular view : 

Card view :

If file is deleted successfully, it will return true else it will return false in a variable defined in Element Key.

 

Verify Text Command

VerifyText command under FILEHANDLER function is used to verify if the given text is present in the file or not.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as verifytext, provide file path in file and text to be checked in text field.

Tabular view :

Card view :

If the given text is found in the file successfully, it will return true else it will return false in a variable defined in Element Key.

 

Rename Command

Rename command under FILEHANDLER function is used to rename a particular file.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as rename, provide file path in file and name which should come after rename in fileAfterRename field.

Tabular view :

Card view :

If the file is renamed successfully, it will return true else it will return false in a variable defined in Element Key.

 

Get File Name With Extension Command

GetFileNameWithExtension command under FILEHANDLER function is used to get the file name with file extension.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as getFileNameWithExt and provide file path in file.

Tabular view :

Card view : 

File name with extension will get stored in a variable defined in Element Key.

 

Get File Name Without Extension Command

GetFileNameWithoutExtension command under FILEHANDLER function is used to get the file name without file extension.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as getFileNameWithoutExt and provide file path in file.

Tabular view : 

Card view :

File name without extension will get stored in a variable defined in Element Key.

 

Create Directory Command

Create Directory command under FILEHANDLER function is used to create a new directory/folder on the specified location.

Select RUN command from the action dropdown and leave Screen and Element Key as blank, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as createDirectory and provide directory/folder path with new folder name at the end of the path.

Tabular view : 

Card view :

Zip Command

Zip command under FILEHANDLER function is used to zip a particular folder.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as zip, provide source and destination.

Tabular view :

Card view :

If the zip is created successfully, it will return true else it will return false in a variable defined in Element Key.

 

Unzip Command

Unzip command under FILEHANDLER function is used to unzip a particular file.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as unzip and provide file path to unzip.

Tabular view :

Card view :

After executing this command, given file will be unzipped at the same location of the file and it will return the path in a variable defined in Element Key.

 

SplitFile Command

SplitFile command under FILEHANDLER function is used to split the files.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as splitFile provide source and lineNos.

Tabular view : 

Card view :

Merge Folders Command

Merge Folders command under FILEHANDLER function is used to merge the content of two folders into given destination folder.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as mergeFolders, provide destination, sourceFolder1 and sourceFolder2.

Tabular view :

Card view :

If the content of both the folders are merged successfully in the destination folder, it will return true else it will return false in a variable defined in the Element Key.

 

Convert CSV to Xlsx Command

Convert CSV to Xlsx command under FILEHANDLER function is used to convert a csv file into xlsx file.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as convertCsvtoXlsx and provide file path in file.

Tabular view : 

Card view :

After execution, file path of converted xlsx file will be returned in a variable defined in Element Key.

 

Convert Excel to CSV Command

Convert Excel to CSV command under FILEHANDLER function is used to convert a excel file into csv file.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select FILEHANDLER function. Select cmd as convertExceltoCsv and provide file path in file.

Tabular view :

Card view :

After execution, file path of converted csv file will be returned in a variable defined in Element Key.

Back To Top