Requirement: To read the xml file from the folder and pass the contents of the file to Soap request.
Issue I am trying to read the file saved in the folder using groovy script, But unable to read the contents of the file. I am getting Null pointer exception while trying to print the contents of the xml file.
def fileList = []
new File("C:\\Users\\Documents\\Groovy Scripts\\requests").eachFile
{ f ->
if (f.isFile()&& f.name.endsWith('.xml'))
{
def filename = f.name[0..-5]
fileList.add(filename)
log.info filename
}
}
if (fileList.size() <1)
{
testRunner.fail("No request files found")
}
context.put('fileList', fileList)
def f = new File("C:\\Users\\Documents\\Groovy Scripts\\requests\\${context.fileList}.last().text")
log.info f
Update based on comments, adding to the question.
My test case contains 3 steps. Step 1: to read the xml file from the folder. Step 2: use the xml file content as soap request input. Step 3: save the response of step 2 in output folder as xml.