Getting values of properties in SoapUI's groovy
Solution 1
In the Groovy script panel you can right-click and select Get Data, to help you out. You will end up with something like this:
context.expand( '${Properties step#SomeProp}' )
Same thing can also be written as:
testRunner.testCase.testSteps['Properties step'].getPropertyValue("SomeProp")
Solution 2
Few cents:
if we are loading properties file through external file via -Dsoapui.properties=\tmp.properties
Contents of tmp.properties
serialNumber=908664374
ideal way to load the property 'serialNumber' in groovy file would be,
def serialnumber = context.expand('${#serialNumber}')
But if you have a property at any level [test suites, test cases or project] inside your SOAPUI project, say you have it at project level, then it would be
def serialnumber1 = context.expand('${#Project#serialNumber}')
Solution 3
The first expression works with:
context.expand( '${Properties_step#SomeProp}' )
Pijotrek
Updated on October 17, 2020Comments
-
Pijotrek over 3 years
I'm pretty new to testing and SoapUI and I've just faced a problem: I have 2 soap requests from which I transfer data (using PropertyTransfer) to Properties - I can do that and it works fine for me. But now I would like to take those values in my groovy script (which is next step of my testcase). How to do that? So far, I have found following:
testRunner.testCase.getPropertyValue("SomeProp")
But it doesn't work for me. I guess it's not that Properties. Any tips?