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

微笑、不失礼 提交于 2019-12-08 14:03:17

问题


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.


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!