Download and verify files
Requirements
- This keyword is applicable for desktop browser testing on Windows and macOS.
- You have installed the Katalon TestCloud Keywords plugin from Katalon Store. If you have not, visit this site: Katalon TestCloud Keywords.
- Follow this guide to install the plugins: Install plugins online from Katalon Store.
When executing WebUI tests with TestCloud, in some scenarios, you may want to download files and verify them. The following is a ready-to-use FileExecutor
class that contains custom keywords for downloading and verify files. The keyword file should be placed under the com.katalon.testcloud
package.
- In Katalon Studio, click the Profile drop-down and select Reload Plugins to make sure the plugin is installed.

- Add the
FileExecutor.pushFiletoDevice
keyword to your test case.

- Configure your TestCloud mobile environment and run the test.
Read and verify file content​
To read the file returned by the keyword FileExecutor.getFileContent
, add the following code snippets to your script:
Read and verify file as String​
String fileName = 'sample-1.csv'
String encodedContent = CustomKeywords.'com.katalon.testcloud.FileExecutor.getFileContent'(fileName)
byte[] decodedBytes = Base64.getDecoder().decode(encodedContent);
WebUI.verifyEqual(new String(decodedBytes).contains('Enter stock symbol in cell B4",,,,,POWERED BY'), true)
Read and verify CSV file as CSV structure​
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.testdata.CSVData
import com.kms.katalon.core.testdata.reader.CSVSeparator
'Get file Content from TestCloud'
String fileName = 'sample-1.csv'
String encodedContent = CustomKeywords.'com.katalon.testcloud.FileExecutor.getFileContent'(fileName)
byte[] decodedBytes = Base64.getDecoder().decode(encodedContent);
'Write the content to a new file'
String newFileLocation = new File(RunConfiguration.getProjectDir() + '/' + fileName).getCanonicalPath()
FileOutputStream outputStream = new FileOutputStream(newFileLocation);
outputStream.write(decodedBytes);
outputStream.close();
'Read the CSV file content (Excluding the headers)'
CSVData csvData = new CSVData(newFileLocation, true, CSVSeparator.COMMA)
List allData = csvData.getAllData()
'Get row 27th, column 2nd'
println allData.get(26).get(1)
Read and verify CSV file with a dynamic file name in CSV structure​
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.testdata.CSVData
import com.kms.katalon.core.testdata.reader.CSVSeparator
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.WebDriver
import org.openqa.selenium.JavascriptExecutor
'Get name of the latest file downloaded on TestCloud'
WebDriver driver = DriverFactory.getWebDriver()
driver.get('chrome://downloads/')
String fileName = ((JavascriptExecutor) driver).executeScript("return document.querySelector('downloads-manager').shadowRoot.querySelector('#downloadsList').items.filter(e => e.state === 2).map(e => e.fileName)[0];")
WebUI.back()
'Get file Content from TestCloud'
String encodedContent = CustomKeywords.'com.katalon.testcloud.FileExecutor.getFileContent'(fileName)
byte[] decodedBytes = Base64.getDecoder().decode(encodedContent);
'Write the content to a new file'
String newFileLocation = new File(RunConfiguration.getProjectDir() + '/' + fileName).getCanonicalPath()
FileOutputStream outputStream = new FileOutputStream(newFileLocation);
outputStream.write(decodedBytes);
outputStream.close();
'Read the CSV file content (Excluding the headers)'
CSVData csvData = new CSVData(newFileLocation, true, CSVSeparator.COMMA)
List<List> allData = csvData.getAllData()
'Get row 27th, column 2nd'
println allData.get(26).get(1)