KarateDSL 从响应中解析值并添加到下一个场景有效负载不起作用

KarateDSL Parsing a value from a response and adding to next scenario payload not working

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

我有一个 post 成功列出所有应用程序的请求,从响应中我得到第一个应用程序的 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

非常感谢任何帮助

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

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

我想如果你注释掉这一行它会起作用:

# Scenario: Get Application