This shows you the differences between two versions of the page.
text_files_adaptor [2019/12/02 15:30] montse [Functions] |
text_files_adaptor [2024/12/10 13:30] (current) montse [Initialization Parameters] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Text Files Adaptor ====== | ====== Text Files Adaptor ====== | ||
+ | =====Description===== | ||
+ | Through the File or Text File Adapter, TAST can manage plain text files and use them in tests. Plain text files are files consisting of text only. That is, they are devoid of formatting information such as bold, underline, italics, font size, typefaces, etc. They do not need to be interpreted to be read, they are more direct, without the distraction of colors, fonts and links, which makes possible the great variety of tests that we can perform with them thanks to TAST. | ||
+ | |||
+ | The Windows Notepad program exclusively handles plain text. We will work with the Notepad ++ version. | ||
+ | |||
+ | As we have seen with other adapters, TAST can perform individual tests with this adapter or it can also perform end-to-end tests by connecting to the rest of the adapters it offers. | ||
===== Initialization Parameters ====== | ===== Initialization Parameters ====== | ||
- | * **FilePath:** The complete path, including the name of the file, of the file represented by the adapter in the diagram. | + | When we include this adapter in a test case, we must provide it with the necessary information to establish the connection and be able to make use of it. It would be the following: |
- | * **CharSet:** The charset used to create the file. For example, if you are using files for Webservice testing, charset must be UTF-8. If you are using files from Windows to one FTP/SFTP server charset must be CP1252.\\ \\ ** IMPORTANT **: It is really important to select properly the charset of the file, the return carriage character is handled in a different way depending on it. It can impact in all the predefine functions managing the file in TAST.\\ \\ To select the proper charset you, it is possible to identify it using the text editor in the following way: | + | |
+ | * **FilePath:** the complete path, including the name of the file, of the file represented by the adapter in the diagram. | ||
+ | * **CharSet:** the charset used to create the file. For example, if you are using files for Webservice testing, charset must be UTF-8. If you are using files from Windows to one FTP/SFTP server charset must be CP1252.\\ \\ ** IMPORTANT:** it is really important to select properly the charset of the file, the return carriage character is handled in a different way depending on it. It can impact in all the predefine functions managing the file in TAST.\\ \\ To select the proper charset you, it is possible to identify it using the text editor in the following way: | ||
- | {{:en:charset_example.png?700|}} | + | {{ :en:charset_example.png?550 |}} |
- | * **Create/Overwrite:** When the checkbox is marked, TAST will create a new file or overwrite it if the file already exists. | + | * **Create/Overwrite:** when the checkbox is marked, TAST will create a new file or overwrite it if the file already exists. |
===== Functions ===== | ===== Functions ===== | ||
- | * **closeFile():** Closes the file and release the associated resources. Returns true if the file could be closed correctly or false otherwise. Input parameters are not required. | + | * **closeFile():** closes the file and release the associated resources. Returns true if the file could be closed correctly or false otherwise. Input parameters are not required. |
- | * **containsText(SearchString):** Returns true if the text string entered in the searchString parameter exists in the file, false otherwise. | + | * **containsText(SearchString):** returns true if the text string entered in the searchString parameter exists in the file, false otherwise. |
- | * **countFileLine():** Returns the number of lines in the file. Input parameters are not required. | + | * **countFileLine():** returns the number of lines in the file. Input parameters are not required. |
- | * **countTextFile():** This function counts the number of times a string appears in a file. The input parameter searchString allow the user to search and execute the comparison. | + | * **countTextFile():** this function counts the number of times a string appears in a file. The input parameter searchString allow the user to search and execute the comparison. |
- | * **deleteFtpFile():** This function deletes a file from the ftp server. Returns if the operation was successful or it was not. The parameters that function needs are: | + | * **deleteFtpFile():** this function deletes a file from the Ftp server. Returns if the operation was successful or it was not. The parameters that function needs are: |
*The Host parameter represents the address of the remote machine where the file resides. | *The Host parameter represents the address of the remote machine where the file resides. | ||
*The User parameter represents the user of connection to the remote system. | *The User parameter represents the user of connection to the remote system. | ||
Line 28: | Line 36: | ||
*The Port parameter represents the port number of the server. | *The Port parameter represents the port number of the server. | ||
- | * **deleteSftpFile():** This function deletes a file from the Sftp server. Returns if the operation was successful or it was not. The parameters that function needs are: | + | * **deleteSftpFile():** this function deletes a file from the Sftp server. Returns if the operation was successful or it was not. The parameters that function needs are: |
*The Host parameter represents the address of the remote machine where the file resides. | *The Host parameter represents the address of the remote machine where the file resides. | ||
*The User parameter represents the user of connection to the remote system. | *The User parameter represents the user of connection to the remote system. | ||
Line 35: | Line 43: | ||
*The Port parameter represents the port number of the server. | *The Port parameter represents the port number of the server. | ||
- | * **generateFileAsEvidence(): The function generates a copy of the file in it's current state to add as evidence. | + | * **formatFileByLenghtLine**: formats file with length entered as parameter. |
- | * **getFileText(): Reads the content of the file and it returns as a TastDataString variable. It does not require input parameters. | + | * **generateFileAsEvidence():** the function generates a copy of the file in it's current state to add as evidence. |
- | + | ||
- | * **generateFileAsEvidence():** The function generates a copy of the file in it's current state to add as evidence. | + | |
- | * **getFtpFile(Host, User, Password, RemotePath, LocalPath):** Allows transferring a file via the Ftp protocol of a remote system to the local system in which the diagram is executed. | + | * **getFileText():** reads the content of the file and it returns as a TastDataString variable. It does not require input parameters. |
+ | |||
+ | * **getFtpFile(Host, User, Password, RemotePath, LocalPath):** allows transferring a file via the Ftp protocol of a remote system to the local system in which the diagram is executed. | ||
* Returns true if the operation is successful, false otherwise. | * Returns true if the operation is successful, false otherwise. | ||
* The Host parameter represents the address of the remote machine where the file resides. | * The Host parameter represents the address of the remote machine where the file resides. | ||
Line 49: | Line 57: | ||
* The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | * The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | ||
- | * **getLineLength(lineNum):** Returns the length of the file line indicated by the lineNum parameter. | + | * **getLineLength(lineNum):** returns the length of the file line indicated by the lineNum parameter. |
- | * **getNumColumns():** Returns the number of columns contained in the TastTableData that was generated by the execution of the loadCsvFile function. **It requires the execution of the loadCsvFile function in previous steps of the diagram**. | + | * **getNumColumns():** returns the number of columns contained in the TastTableData that was generated by the execution of the loadCsvFile function. **It requires the execution of the loadCsvFile function in previous steps of the diagram**. |
- | * **getOwner():** Return file 's owner in the filesystem. Input parameters are not required. | + | * **getOwner():** return file 's owner in the filesystem. Input parameters are not required. |
- | * **getReadLine(LineNum):** Returns a variable of type String to the executor with the content of the number of line indicated by the numLine parameter. | + | * **getReadLine(lineNum):** returns a variable of type String to the executor with the content of the number of line indicated by the lineNum parameter. |
- | * **getSftpFile(Host, Port, User, Password, RemotePath, LocalPath):** Allows transferring a file via the Sftp protocol of a remote system to the local system in which the diagram is executed. | + | * **getSftpFile(Host, Port, User, Password, RemotePath, LocalPath):** allows transferring a file via the Sftp protocol of a remote system to the local system in which the diagram is executed. |
* Returns true if the operation is successful, false otherwise. | * Returns true if the operation is successful, false otherwise. | ||
* The Host parameter represents the address of the remote machine where the file resides. | * The Host parameter represents the address of the remote machine where the file resides. | ||
- | * The Port parameter represents the port number on which the SFTP server listens for incoming connections. The SFTP takes port 22 by default. | + | * The Port parameter represents the port number on which the Sftp server listens for incoming connections. The Sftp takes port 22 by default. |
* The User parameter represents the user of connection to the remote system. | * The User parameter represents the user of connection to the remote system. | ||
* The Password parameter represents the user's password on the remote system. | * The Password parameter represents the user's password on the remote system. | ||
Line 66: | Line 74: | ||
* The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | * The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | ||
- | * **getSize():** Returns the file size in KiloBytes. Input parameters are not required. | + | * **getSize():** returns the file size in KiloBytes. Input parameters are not required. |
- | * **getTableValue(RowNum, ColNum):** Returns the contained value of the cell indicated by the RowNum and ColNum parameters. **It requires the execution of the loadCsvFile function in previous steps of the diagram**. | + | * **getTableValue(RowNum, ColNum):** returns the contained value of the cell indicated by the RowNum and ColNum parameters. **It requires the execution of the loadCsvFile function in previous steps of the diagram**. |
- | * **getTextFileData():** Keeps all the content of the file in an array and another file for futures operations. It does not require input parameters. | + | * **getTextFileData():** keeps all the content of the file in an array and another file for futures operations. It does not require input parameters. |
- | * **lineContainsText(lineNum, StringToSearch):** Returns true if the text string entered in the StringToSearch parameter exists in the line of the file indicated by the lineNum parameter, and false otherwise. | + | * **lineContainsText(lineNum, StringToSearch):** returns true if the text string entered in the StringToSearch parameter exists in the line of the file indicated by the lineNum parameter, and false otherwise. |
- | * **loadCsvFile(Separator):** Reads the contents of a csv-type file, and transforms it into a TastTableData variable that is returned to the executor so that we can operate on the data in the next steps of the diagram. The separator parameter indicates the separator character of fields in the file. | + | * **loadCsvFile(Separator):** reads the contents of a csv-type file, and transforms it into a TastTableData variable that is returned to the executor so that we can operate on the data in the next steps of the diagram. The separator parameter indicates the separator character of fields in the file. |
- | * **newFile(FilePath):** Creates or overrides a file, with the path and the name indicated by the parameter "filePath".\\ If the file doesn´t exist, TAST will create it, as an empty file.\\ If the file exist, TAST will delete the current file, and it will create a new empty one. | + | * **newFile(FilePath):** creates or overrides a file, with the path and the name indicated by the parameter "filePath".\\ If the file doesn´t exist, TAST will create it, as an empty file.\\ If the file exist, TAST will delete the current file, and it will create a new empty one. |
- | * **openFile():** Checks the existence of the file in the file system, and the reads / writes permissions on it. Returns true if the file could be accessed correctly or false otherwise. Input parameters are not required. | + | * **openFile():** checks the existence of the file in the file system, and the reads / writes permissions on it. Returns true if the file could be accessed correctly or false otherwise. Input parameters are not required. |
- | * **openNewFile():** Resets the content of the configured file to empty. This file must exist. Input parameters are not required. | + | * **openNewFile():** resets the content of the configured file to empty. This file must exist. Input parameters are not required. |
- | * **putFtpFile(Host, User, Pasword, LocalFileName, RemoteFileName, HostDirectory):** Allows to transfer a file, by the Ftp protocol, of the local system in which the diagram is executed to the remote system. | + | * **putFtpFile(Host, User, Pasword, LocalFileName, RemoteFileName, HostDirectory):** allows to transfer a file, by the Ftp protocol, of the local system in which the diagram is executed to the remote system. |
* Returns true if the operation is successful, false otherwise. | * Returns true if the operation is successful, false otherwise. | ||
* The Host parameter represents the address of the remote machine where the file resides. | * The Host parameter represents the address of the remote machine where the file resides. | ||
Line 91: | Line 99: | ||
* The HostDirectory parameter represents the directory, in the remote file system, where we want to transfer the file. | * The HostDirectory parameter represents the directory, in the remote file system, where we want to transfer the file. | ||
- | * **putSftpFile(Host, Port, User, Password, LocalPath, RemotePathFormed):** Allows to transfer a file, by the Sftp protocol, of the local system in which the diagram is executed to the remote system. | + | * **putSftpFile(Host, Port, User, Password, LocalPath, RemotePathFormed):** allows to transfer a file, by the Sftp protocol, of the local system in which the diagram is executed to the remote system. |
* Returns true if the operation is successful, false otherwise. | * Returns true if the operation is successful, false otherwise. | ||
* The Host parameter represents the address of the remote machine where the file resides. | * The Host parameter represents the address of the remote machine where the file resides. | ||
Line 100: | Line 108: | ||
* The RemotePathFormed parameter represents the full path and the name of the file on the remote system. | * The RemotePathFormed parameter represents the full path and the name of the file on the remote system. | ||
- | * **replaceText(From_Str, To_Str):** Allows to replace all the occurrences of the string "From_Str" by the string "To_Str", and will save the file again. | + | * **replaceText(From_Str, To_Str):** allows to replace all the occurrences of the string "From_Str" by the string "To_Str", and will save the file again. |
+ | |||
+ | * **searchText**: returns a list of lines containing the texts entered as input parameters. | ||
- | * **writeEnter:** The function append a carriage return to the file. Input parameters are not required. | + | * **writeEnter:** the function append a carriage return to the file. Input parameters are not required. |
- | * **writeTo(StringToWrite):** Writes the text string in the file, in append mode. | + | * **writeTo(StringToWrite):** writes the text string in the file, in append mode. |
- | * Returns true if the write operation was successful, false otherwise. The input parameters are stringToWrite to receive the text string and addBreakLine to skip the line (this parameter is a Boolean). | + | * Returns true if the write operation was successful, false otherwise. The input parameters are StringToWrite to receive the text string and addBreakLine to skip the line (this parameter is a Boolean). |