如何在另一个请求中发送已保存的身份验证令牌?

时间:2018-11-19 10:17:09

标签: karate

Scenario: Verify that Authentication is done or not
Given url '***********'
Given path 'authenticate'
And form field username = 'admin_cs'
And form field password = '********'
When method post
Then status 200
And header tokenn = response.token

* def accessToken = response.token

* print accessToken


Scenario: Verify Get all Clients

Given url '************'
Given path 'users/usersAssignable'
* header x-auth-token = accessToken
When method get
Then status 200
* def response = response
* print response

1 个答案:

答案 0 :(得分:0)

请将两个Scenario-合并为一个。或将第一个移到Background中。请仔细阅读以下内容:https://github.com/intuit/karate#script-structure