Forum Discussion

Lachulearns's avatar
Lachulearns
New Contributor
6 years ago

Request Not Modified

I need to test multiple requests in a same testcase.Below Steps have been followed to achieve this.

  1. Declared Property at Testsuite Level (eg. Number  1,2,3)
  2. Split those values and set the property in Property Step level. So each time during the iteration the property at Property Step will change.
  3. Then run the request.                           

But the issue i am facing is, the property at PropertyStep gets updated for every iteration. But the values is not passed to the request.

 

This is my code.

 

ef number = testRunner.testCase.testSuite.getPropertyValue( "number" )
String[] nu = number.split(",")
for (int i=0;i<nu.size();i++)
{
nums=nu[i]
testRunner.testCase.testSteps["Prop"].setPropertyValue( "number",nums )
def prop = testRunner.testCase.testSteps["Prop"].getPropertyValue( "number" )
log.info prop
def Response = ""

Response = testRunner.testCase.testSteps["request1"].testRequest.response.contentAsString
log.info Response
def file = new PrintWriter ("C:\\Users\\Laksh\\PycharmProjects\\BRMCODE\\response_"+i+".xml")
file.println(Response)

file.close()
}

 

  • In the above code i am getting only the response without running.

    i have included the below code to run the Request.This Helps

     

    reqrun= testRunner.testCase.testSteps["request1"]

    Response= reqrun.run(testRunner,context)

    Response.getResponse().responsecontent

  • Lachulearns's avatar
    Lachulearns
    New Contributor

    Lachulearns wrote:

    I need to test multiple requests in a same testcase.Below Steps have been followed to achieve this.

    1. Declared Property at Testsuite Level (eg. Number  1,2,3)
    2. Split those values and set the property in Property Step level. So each time during the iteration the property at Property Step will change.
    3. Then run the request.                           

    But the issue i am facing is, the property at PropertyStep gets updated for every iteration. But the values is not passed to the request.

     

    This is my code.

     

    ef number = testRunner.testCase.testSuite.getPropertyValue( "number" )
    String[] nu = number.split(",")
    for (int i=0;i<nu.size();i++)
    {
    nums=nu[i]
    testRunner.testCase.testSteps["Prop"].setPropertyValue( "number",nums )
    def prop = testRunner.testCase.testSteps["Prop"].getPropertyValue( "number" )
    log.info prop
    def Response = ""

    Response = testRunner.testCase.testSteps["request1"].testRequest.response.contentAsString
    log.info Response
    def file = new PrintWriter ("C:\\Users\\Laksh\\PycharmProjects\\BRMCODE\\response_"+i+".xml")
    file.println(Response)

    file.close()
    }

     



    In the above code i am getting only the response without running.

    i have included the below code to run the Request.This Helps

     

    reqrun= testRunner.testCase.testSteps["request1"]

    Response= reqrun.run(testRunner,context)

    Response.getResponse().responsecontent

  • Lachulearns's avatar
    Lachulearns
    New Contributor

    In the above code i am getting only the response without running.

    i have included the below code to run the Request.This Helps

     

    reqrun= testRunner.testCase.testSteps["request1"]

    Response= reqrun.run(testRunner,context)

    Response.getResponse().responsecontent