如何将变量插入“Xpath selection”在SoapUI的财产转移 [英] How to insert variable into "Xpath selection" of Property Transfer in SoapUI

查看:89
本文介绍了如何将变量插入“Xpath selection”在SoapUI的财产转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SoapUI 4.6.1
我有TestCase,其中包括:


  1. 测试请求(1)
  2. >
  3. Groovy脚本

  4. 属性传输

  5. 测试请求(2)

我的目标是将变量从Groovy脚本的结果传递给Property Transfer的Xpath表达式。为了什么?



测试请求(1)响应中,有一系列计划:

 < ...> 
< ...>
< ...>
< scheme_list>
< scheme>
< node1>
...
< / node1>
...
< nodeN>
...
< / nodeN>
< / scheme>

< scheme>
< node1>
...
< / node1>
...
< nodeN>
...
< / nodeN>
< / scheme>

< scheme>
< node1>
...
< / node1>
...
< nodeN>
...
< / nodeN>
< / scheme>
< / scheme_list>
< /...& gt;
< /...& gt;
< /...& gt;

Groovy脚本从其他所有方面找到1个方案,这与我的条件相符。 脚本的结果 - 是此计划的数字

  ... 
返回i

属性传输中,我需要传递方案的所有节点我发现测试请求(2)。所以,我只需要将这个方案的数目传递给Xpath表达式。



我认为这很容易:

 来源:// scheme_list / scheme [i] 
目标://计划

或我在互联网上找到的解决方案:

 来源:// scheme_list / scheme ['+ i +'] 
目标://计划

但不幸的是,没有工作。我的变量i位于Groovy Script中,不能在某处传递,就像另一个测试步骤Property Transfer。

解决方案

纵观许多问答,我尝试了很多不同的解决方案,但是找到了我自己的(我猜)。

  // scheme_list / scheme [$ {path#result}] 

其中路径为脚本名称和结果是结果。

1条件是您返回所需的变量作为脚本的结果

因此,您可以将变量从脚本到Xpath。



如果有更简单的解决方案,请分享。


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.

解决方案

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.

这篇关于如何将变量插入“Xpath selection”在SoapUI的财产转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆