【问题标题】:KarateDSL Parsing a value from a response and adding to next scenario payload not workingKarateDSL 从响应中解析值并添加到下一个场景有效负载不起作用
【发布时间】:2018-09-04 17:17:18
【问题描述】:

空手道新手,我已经阅读了大量的空手道教程,但无法理解这个看似微不足道的问题。

我有一个成功列出所有应用程序的发布请求,从响应中我得到第一个应用程序的 ID 并将其打印到控制台,它显示没有问题。但是,当我在下一个场景中使用有效负载中的 applicationId 时(在同一功能文件中,applicationId 不会添加到有效负载中。

Scenario: List all applications
Given path '/ListApplications'
And request {"request":{},"Session":'#(session)'}
When method POST
Then status 200
And def applicationId = response.Applications[0].Id
* print 'Hello ' + applicationId //i see the application id of 7203 here in the console log

Scenario: Get Application
Given path '/GetApplication'
And request {"request":{"ApplicationId":'#(applicationId)'},"Session":'#(session)'} 
When method POST //post here just uses string applicationId instead of 7203
Then status 200

非常感谢任何帮助

【问题讨论】:

    标签: karate


    【解决方案1】:

    您正在使用 2 个Scenarios,而您应该只有一个。

    请阅读文档的这一部分:https://github.com/intuit/karate#script-structure

    我认为如果您注释掉这一行,它将起作用:

    # Scenario: Get Application 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多