I am new to Groovy scripting.
Requirement To read the request values from a text file and pass it to the soap request xml and save the output.
Issue facing: I am not able to read the data from step 1 to step 2. However I am setting the values in context variable as well. Kindly help me to fix the issue so that I can able to automate the entire process.
Note: We have only access to SOAPUI not SOAPUI Pro
Step 1:
File file1 = new File("C:\Users\Groovy Test\requests\orders.txt")
List textLine = file1.readLines()
log.info textLine
context.put('textLine', textLine)
log.info textLine
Step 2:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<OrderId>${context.get('textLine' )}</OrderId>
</soapenv:Body>
</soapenv:Envelope>
Step 3:
def fileList = context.get('textLine')
def fileName = fileList.pop()
def newname = fileName[0..-5]
def response = context.expand( '${Step2#Response}' )
def f = new File("C:\Users\Groovy Test\responses\${fileName}_Response.xml")
f.write(response, "UTF-8")
if(fileList.size() >0)
{
testRunner.gotoStepByName("Step2")
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…