如何使用-in-karate框架Ex:Attribute auth-token获取json值
帮助解决下面的问题 变量:如何使用-in-karate框架Ex:Attribute auth-token获取json值,json,testing,frameworks,karate,Json,Testing,Frameworks,Karate,帮助解决下面的问题 变量: * def token = loginResponse.response.data.attributes.auth-token 错误: -未知-:7-javascript评估失败:loginResponse.response.data.attributes.auth-token,ReferenceError: 第1行中未定义“令牌” com.intuit.karate.exception.karateeexception:-未知-:7-javascript 评估失败
* def token = loginResponse.response.data.attributes.auth-token
错误:
-未知-:7-javascript评估失败:loginResponse.response.data.attributes.auth-token,ReferenceError:
第1行中未定义“令牌”
com.intuit.karate.exception.karateeexception:-未知-:7-javascript
评估失败:loginResponse.response.data.attributes.auth-token,
ReferenceError:“令牌”未在第1行中定义
✽.* def token=loginResponse.response.data.attributes.auth-token
(-未知-:7)
Schemma json:
{
"data": {
"id": "3326",
"type": "users",
"attributes": {
"email": "emerson@gmail.com",
"auth-token": "3ve6mPU4G-txLBmvc5eJ",
"created-at": "2020-04-19T17:30:54.031Z",
"updated-at": "2020-04-21T17:47:39.649Z"
}
}
}
请求:
Scenario: List tasks
Given path '/tasks'
And header Accept = " application/vnd.tasksmanager.v2"
And header Authorization = token
When method GET
Then status 200
对于JSON键中的特殊字符,请使用方括号访问:
* def token = loginResponse.response.data.attributes['auth-token']
对于JSON键中的特殊字符,请使用方括号访问:
* def token = loginResponse.response.data.attributes['auth-token']