Forum Discussion

pkiddie's avatar
pkiddie
Occasional Contributor
15 years ago

Get response from RequestTestSteps

Hi,

Is there any way of getting LoadUI to output the 'Response' property from a RequestTestStep in a table log when you set the output level to 'TestCase and RequestTestSteps'? I've used a 'Property Transfer' step after the Request step but it only runs if the Request assertions pass, whereas I would like to output the response field regardless.

Best,
Paul

3 Replies

  • abhishek813's avatar
    abhishek813
    Frequent Contributor
    Have you tried using groovy to export save the request and response xmls?
  • pkiddie's avatar
    pkiddie
    Occasional Contributor
    Hi abhishek813,

    Do you have any code snippets you could share to achieve this?

    Cheers,
    Paul
  • abhishek813's avatar
    abhishek813
    Frequent Contributor
    Sorry for the delay Paul, try the below code:

    request = context.expand( '${TestRequest#Request}' )
    response = context.expand( '${TestRequest#Response}' )
    xmlDir = "C:\\temp\\"

    //make relevant directory and save request-response XMLs

    //request and response XML full path
    reqXMLPath = xmlDir + "reqXML.xml"
    respXMLPath = xmlDir + "respXML.xml"

    def file2 = new PrintWriter (reqXMLPath)
    file2.println(request)
    file2.flush()
    file2.close()

    def file = new PrintWriter (respXMLPath)
    file.println(response)
    file.flush()
    file.close()