我正在访问 API 端点并得到如下所示的信息。
{
"emp": {
"id": "123",
"firstNm": "test",
"lastNm": "last",
"dob": "200-01-01",
"gender": {
"code": "F",
"name": "Female",
"description": "Female"
},
"test1": [
{
"tes2": "F50045A3B994FB2BDF4E3D3FC906F592",
"t2": "a23",
"test3": {
"code": "432",
},
"ind": [
"ABC",
"BCD",
]
}
]
}
}
我想匹配数组中的元素
"ind": [
"ABC",
"BCD",
]
我已经尝试过以下方法:
Feature: test
Background:
* url BaseUrl
* configure headers = read('classpath:headers.js')
Scenario Outline: test
Given path '/path'
And param id = <id>
When method get
Then status 200
* def json = response
* def has = {ind:['#string'] }
* def indicator = { ind: '#[] has' }
* match json.member == '#[] indicator'
Examples:
| id |
| '1234' |
但观察到以下异常:
预期:'#[] ind',原因:不是数组或列表
有人可以帮忙吗?
我并没有真正遵循您的逻辑,因为指标不在 json 响应或定义的变量中,但要访问 ind 数组,路径是 emp.test1[0].ind
如果你想匹配数组有 ABC 和 BCD 你会做以下
* match response.emp.test1[0].ind == ['ABC', 'BCD']
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)