我得到了一系列URL作为响应。我想检查数组中的每个URL是否包含一个特定的单词。 如何在空手道框架中检查此内容? 我的回答是:
response {
"docs":[{
"url":"http://url/1.com"
"title": "some title"
},{
"url":"http://url/2.com"
"title":"ABC"
}]
}
}
现在,我要检查每个url字段值中是否都包含单词'url'。如何检查此内容,因为match each $.response.docs.url contains 'url'
对我不起作用。
答案 0 :(得分:0)
请参考match each
语法。这是一个示例:
* def response = [ 'http://url-one.com', 'http://url-two.com', ]
* match each response contains 'url'
编辑-编辑问题后。这是您的工作示例:
* def response =
"""
{
"docs":[
{
"url":"http://url/1.com",
"title":"some title"
},
{
"url":"http://url/2.com",
"title":"ABC"
}
]
}
"""
* def urls = $response.docs[*].url
* match each urls contains '/url/'