-1
    1.Read the data.xml file from feature file.
    
    2.Replace tag value <UID> to random values - **First I have tried to replace with a hard-coded value,but no changes**
    
    3.Go for POST method and get the response
    
    data.xml and Test.feature file snippet is mentioned below -
    
    **1.data.xml**
    
    <Test>
      <First>
         <UID>87abc65</UID>
         <Second>Food</Second>
      </First>
    </Test>
    
    **2.Test.feature**
Explained the replace in below code -
   

场景:获取输出

  • def req = read('data.xml')

  • 替换请求

| 令牌 | 价值 |

| @@UID@@ | '12345' |

  • xml 请求 = 请求

并请求req

当方法 POST

然后状态 200

4

1 回答 1

0

也许set更好:

* set req/Test/First/UID = '12345'

否则你不明白替换。请仔细阅读文档:https ://github.com/intuit/karate#replace

于 2020-07-26T18:03:44.560 回答