问题
working with SoapUI 4.6.1 I have TestCase, which includes:
- Test Request (1)
- Groovy Script
- Property Transfer
- Test Request (2)
My goal is to pass variable from result of Groovy Script to Xpath expression of Property Transfer. For what?
In Test Request (1) Response, there's list of schemes:
<...>
<...>
<...>
<scheme_list>
<scheme>
<node1>
...
</node1>
...
<nodeN>
...
</nodeN>
</scheme>
<scheme>
<node1>
...
</node1>
...
<nodeN>
...
</nodeN>
</scheme>
<scheme>
<node1>
...
</node1>
...
<nodeN>
...
</nodeN>
</scheme>
</scheme_list>
</...>
</...>
</...>
Groovy Script finds 1 scheme from all others, which corresponds to my conditions. Result of the script - is the number of this scheme:
...
return i
In Property Transfer, I need to pass all nodes of scheme i found to Test Request (2). So, I just need to take number of this scheme and pass it to Xpath expression.
I thought it would be easily:
Source: //scheme_list/scheme[i]
Target: //scheme
or solution i found in internet:
Source: //scheme_list/scheme['+i+']
Target: //scheme
But, unfortunately, it doesn't work. My variable "i" locates in Groovy Script and can't be passed somewhere out, like another test step Property Transfer.
回答1:
Looking through many Q&A, i tried a lot of different solutions, but found my own (i guess).
//scheme_list/scheme[${path#result}]
Where path is script name and result is result.
1 condition is that you return needed variable as result of your script
So, you can pass variables from script to Xpath.
If there's a much more simple solution, please share.
来源:https://stackoverflow.com/questions/43889194/how-to-insert-variable-into-xpath-selection-of-property-transfer-in-soapui