Documentation

Filehandle function

This function is used to handle file processing like watching file in a folder, copy and paste a particular extension file, delete a file and verify text from the file.

Select SET command from the Action drop-down, leave the Screen name blank, Give a variable name in the Element key and provide the file handler function in the parameter section as shown below:

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

This function perform four actions as given below:

  • Watch
  • Copy
  • Delete
  • Verifytext

Watch:

Watch is used to find out the exact path of a file by looking into a folder using file extension.

Syntax: ${__filehandle(cmd=action name,folder=folder path,extension=extension type,prefix=file name prefix, timeout=time taken to search the file)}

where, cmd denotes the command user wants to perform like the watch. folder denotes which folder is to be watched extension is the file extension to watch in a particular folder example txt, xls, pdf, etc. prefix is the filename prefix if the user wants to give timeout denotes time taken to search the file.

Note: prefix and time out is an optional parameter and if timeout is not given explicitly then default timeout is 5 minutes.

Example: ${__filehandle(cmd=watch,folder=C:\BeatBlip\DemoTwo\sourcelocation,extension=txt)}

In the above example spath is the name of a variable which will store the complete path of the file.

Copy:

Copy is used to copy the file from source location to destination folder.

Example: ${__filehandle(cmd=copy,source=C:\BeatBlip\Demo1\file1.txt,destination=C:\BeatBlip\Demo2)}

In the above snapshot, output variable will be set with true if file is copied successfully.

Delete:

Delete is used to delete a particular file.

Example: ${__filehandle(cmd=delete,file= C:\BeatBlip\Demo1\file1.txt )}

For verifytext:

verifytext is used to verify if the given text is present in the file or not.

Example: ${__filehandle(cmd=verifytext,file= C:\BeatBlip\Demo1\file1.txt ,text=Hello)}

Was this page helpful?