Forum Discussion

abgo's avatar
abgo
New Contributor
15 years ago

How to retrieve property value in groovy script

I have been trying to retrieve property value in a groovy assertion script. Execution of my test case is as follow

1) Connect to DB and retireve values
2) Transfer the values to properties using property transfer
3) Run the WS request and validate response against the properties in previous step.

I have successfully used XPATH assertion for content but the problem begins when the data is null. Database, although return null values, the property transfer modify it to an empty string and the XPATH assertion fails and I get the following error: 
XPathContains comparison failed, expecting [], actual was [null]


I thought the workaround to this could be to parse the values in groovy script and then compare it but I can't seem to figure out how to access property values transferred in previous step.

Any suggestions welcome.

thanks,
abgo

1 Reply

  • abgo's avatar
    abgo
    New Contributor
    I finally figured it out. you can use the following to retrieve properties in assertion groovy script


    def value = context.getProperty("<your_properties_step_name"#<property_name>")


    please let me know if there is any other way of doing it. Otherwise, I hope this helps somebody in future.