Reading from a text file is no longer working

Katalon Studio Version:
KSE 8.6.6, Build 208
Windows 11 Enterprise (64-bit)
Chrome Version: 117.0.5938.132 (Official Build) (32-bit)

Reading from a text file is no longer working for our team, is anyone else seeing this issue?
The following previously worked (How would I read from a text file - #5 by Dave_Evers).

Import section:


Test case body:

File file = new File('C:\\Users\\qatester\\Downloads\\TestFiles\\mytest.txt')
println file.getText("UTF-8")

=============== ROOT CAUSE =====================

For trouble shooting, please visit:

10-03-2023 11:33:10 AM Test Cases/01 How_to_cases/25 Katalon_tips/00 ReadFromDave.txt

Elapsed time: 0.385s

Test Cases/01 How_to_cases/25 Katalon_tips/00 ReadFromDave.txt FAILED.
Reason: C:\Users\qatester\Downloads\TestFiles\mytest.txt (The system cannot find the file specified)
	at 00 ReadFromDave.txt:4)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
	at com.kms.katalon.core.main.TestCaseExecutor.execute(
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)

1 Like

Sorry folks this is working as expected we had a naming typo in our text file… File name was mytest…txt when it should have been mytest.txt The error was having two periods after the file name.

import java.nio.file.Path
import java.nio.file.Paths
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

//Hardcoded path
File file1 = new File('C:/Users/qatester/Downloads/TestFiles/mytext.txt')
println file1.getText("UTF-8")

//system user path
def SysUserDownloadDir = (System.getProperty('user.home'))
Path SysUserPath = Paths.get(SysUserDownloadDir)
Path SysUserTestFile = SysUserPath.resolve('Downloads').resolve('TestFiles').resolve('mytext.txt')
def textFile = SysUserTestFile.toString()
println("textFile: " + textFile)
//result = textFile: C:\Users\qatester\Downloads\TestFiles\mytext.txt
File file2 = new File(textFile)
String FileContents = file2.getText("UTF-8")
println FileContents