Forum Discussion

TestTestTest's avatar
TestTestTest
New Contributor
6 years ago
Solved

Groovy: Read Response using xpath in a soapui property

Hi,   I'm trying to replace the xpath with a soapui parameter that eventually will come from a csv, but errors keep showing up. This is the code.     testRunner.testCase.setPropertyValue( "...
  • TestTestTest's avatar
    TestTestTest
    6 years ago

    Hi,

     

    Thanks to another tester we found the solution. I was missing a step.

    I was not able to use the ${TestCase#property} due to error messages in the groovy script. 

    But is was not aware that you have to declare al local variable first if you want to use the property in the groovy script. So my solution was: 

     

    step 1: fill the csv file

    ----csv file contents

    //person/sex

     

    step 2: put csv into array

    FIle filereader..etc..

    testcase.setproperty("xpath_from_csv", propdata[0])

     

    step 3: declare the property as a local variable in groovy

    xpath =  context.expand ( '${#TestCase#xpath_from_csv} ')

     

    step 4: get the value from the response

    testcase.setproperty("sex_from_response", response[$xpath] )     //xpath comes from csv fil

     

    thank for all the help.