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

橙三吉。 提交于 2019-12-13 01:09:08

问题


New to Karate and I have read a load of the Karate tutorials and cannot get my head around what looks to be a trivial issue.

I have one post request that successfully lists all applications, from the response I get the ID of the first application and print it to console and it displays with no issue. However, when I come to use the applicationId in the payload for the next scenario (int he same feature file, the applicationId is not added to the payload.

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

Any help greatly appreciated


回答1:


You are using 2 Scenarios where you should have only one.

Please read this section of the docs: https://github.com/intuit/karate#script-structure

I think if you comment out this line it will work:

# Scenario: Get Application 


来源:https://stackoverflow.com/questions/52159904/karatedsl-parsing-a-value-from-a-response-and-adding-to-next-scenario-payload-no

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!