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( "var_xpath_old", "//person/sex/") // will be in a csv
//Response is here
testRunner.testCase.setPropertyValue( "var_old", response["//person/sex") //<-- this is where is want to inject var_xpath_old
any ideas?
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.