【发布时间】:2019-01-31 16:18:41
【问题描述】:
响应正文的输出
{"data":[{"id”:122,"name”:”Test 1“,”description”:”TEST 1 Test 2 …..}]},{"id”:123,"name”:”DYNAMO”……}]},{"id”:126,”name”:”T DYNAMO”……
*** Keywords ***
Capture The Data Ids
@{ids}= Create List 122 123 126 167 190
${header} Create Dictionary Authoriztion...
${resp} Get Response httpsbin /data
${t_ids}= Get Json Value ${resp.content} /data/0/id
问题
我在测试用例中创建了上述 id 的列表,我需要将创建的数据与响应正文中返回的 id 进行比较。 t_ids 返回 122,当 0 被 1 替换时,返回 123
除了捕获单个 id 之外,是否可以将它们放入 for 循环中?
:FOR ${i} IN ${ids}
\ ${the_id= Get Json Value ${resp.content} /data/${i}/id ?
我试过了,但失败了。
将响应数据中的 id 与创建的列表进行比较的可能解决方案是什么?
谢谢。
【问题讨论】:
标签: json python-2.7 robotframework