Forum Discussion

ravibabu_it's avatar
ravibabu_it
Occasional Contributor
8 years ago

Unable to set Rest URI template parameters using groovy script.

I am using REST URI template service for my testing and URI looks as below:


http://XXX.XX.X.XX:XXXX/HawkService/dh/Login/{userid}/{pwd}

 

I am getting my userid and pwd parameters and its values from external file..

 

parameters: userid,pwd
values:xxx,xx

 

I am able to read the parameters and values successful from external files but when i execute the below code it is not setting the parameters and values to the request.

 

for (intcount=0;intcount<tagsize;intcount++)
{
log.info (intcount)
inputtagList =inputtagArray.getAt(intcount);
log.info " after split :$inputtagList"
inputValueList = inputValueArray.getAt(intcount)
log.info " after split :$inputValueList"
log.info(ServiceName)
log.info(methodname)
****** i am tring to set the parameters and values at the below step **********
context.testCase.testSuite.project.testSuites["Services"].testCases[ServiceName].testSteps[(methodname)].setPropertyValue(inputtagList.getAt(intcount),inputValueList.getAt(intcount))


}

I browsed google and this forum and still unable to find a solution for this.. Any help is greatly appreciated.

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    In the template define parameter and value (as test case level property)

    Say
    parameter1 as parameter name and
    ${#TestCase#PARAMETER1_VALUE} as parameter value.

    In your groovy script, set test case level property value to PARAMETER1_VALUE
    like
    context.testCase.setPropertyValue('PARAMETER1_VALUE', 'value')
    • ravibabu_it's avatar
      ravibabu_it
      Occasional Contributor

      Thanks NMRAO for looking into it.

       

      Actually We are creating framework where all the required data like service name, method and input parameters and values comes from external file. I have created excel function to read the data using POI which is working fine. I have attached screenshot that contains my framework setup.  Do you see any issue in my code why it is not able to set the parameter and its value?

      • nmrao's avatar
        nmrao
        Champion Level 3
        My earlier reply already address that.

        Currently there is no value for user name and password. Please add values as property expansion.