Nikita Rysin
Nikita Rysin

Reputation: 29

How to insert variable into "Xpath selection" of Property Transfer in SoapUI

working with SoapUI 4.6.1 I have TestCase, which includes:

  1. Test Request (1)
  2. Groovy Script
  3. Property Transfer
  4. 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.

Upvotes: 0

Views: 1115

Answers (1)

Nikita Rysin
Nikita Rysin

Reputation: 29

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.

Upvotes: 1

Related Questions