Forum Discussion

rajivr's avatar
15 years ago

Datagen issue

Hi, I have a datagen step prior to running a webservice call. It has a variable initid which I have set it up to a random number between 1 and 100. In the request I am referencing the variable as follows: <intiatorId>${#initid}</intiatorId>. The problem is in the database, I see the value 0 being inserted. Am I referencing the variable correctly?
  • galford's avatar
    galford
    Occasional Contributor
    Hi,

    One possible solution is to save the value of the variable "initd" into the properities file.
    Then to use its value into the request.


    Here is an example:

    //This initialize the properties file which will be used into the groovy script.
    def initParams = testRunner.testCase.getTestStepByName( "initParameters" );

    //This will save the current value of the "initd" into the propertiesFile "initParameters"

    initParams.setPropertyValue("initd",String.valueOf(initd))

    //This will display into the log the current value of initd
    log.info("The vallue of the the initd: ${initd} ")

    I hope that will help you