Forum Discussion

Kate1's avatar
Kate1
New Contributor
7 years ago
Solved

Change dynamic variable in loop Rest SoapUI

Hi!

I can't dynamic change variable in URL. I have URL for example: https://community.smartbear.com/t5/1234?action=update?status=acive and I would like change dynamic in loop paramter '1234'. For example I have array ids = [1,2,3,4,5,6,7] and I woulde like to create TestCase witch excute seven time restRequest with varoius {id}. So I create TestCase (GroovyScript and RestRequest) but I don't know how change value {id} and make this in loop. Do you have any ides?

 

  • Add a groovy step with something like this. In your REST step parameter reference the id number like this ${#TestCase#id}. For each loop a new id will be created for the request. There are many ways to achieve this same thing.

     

    def i = 1

    while (i < 8){
    String id = i
    context.testCase.setPropertyValue("id", id)
    testRunner.runTestStepByName( "REST_REQUEST") //disable your REST_REQUEST step and let the groovy script drive the execution
    i++
    }

4 Replies

  • Kate1's avatar
    Kate1
    New Contributor

    @bagochips  thanks for your reply but I made this 

     

    How  can I dynamic change this value in RestRequest or GroovyScript? I have lots of ids.

    • bagochips's avatar
      bagochips
      Contributor

      Add a groovy step with something like this. In your REST step parameter reference the id number like this ${#TestCase#id}. For each loop a new id will be created for the request. There are many ways to achieve this same thing.

       

      def i = 1

      while (i < 8){
      String id = i
      context.testCase.setPropertyValue("id", id)
      testRunner.runTestStepByName( "REST_REQUEST") //disable your REST_REQUEST step and let the groovy script drive the execution
      i++
      }