首页 文章

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

提问于
浏览
1

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

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

任何帮助非常感谢

1 回答

  • 1

    您正在使用2 Scenario s,您应该只有一个 .

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

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

    # Scenario: Get Application
    

相关问题