karate - 在空手道框架中,无法通过解析获取 xml 响应中的值
问题描述
努力在我的 POC 中将空手道项目作为工具,这是我的要求 - http://www.mocky.io/v2/5d7267732f00004a007d4cb1
我在空手道中使用了下面的代码
Given url 'http://www.mocky.io/v2/5d7267732f00004a007d4cb1'
When method GET
Then status 200
Then print response
And match response == expectedoutput
* def val = $expectedoutput/Group/Elements/Group/Elements/Group[0]/Elements/Set
And print 'value is' , val
它抛出一个错误 -
com.intuit.karate.exception.KarateException:userxmlDetails.feature:12 - xpath 不存在:/Group/Elements/Group/Elements/Group[0]/Elements/在✽的预期输出上设置。* def val = $expectedoutput/ Group/Elements/Group/Elements/Group[0]/Elements/Set (userxmlDetails.feature:12)
我也试过expectedoutput/Group/Elements/Group/Elements/Group[0]/Elements/Set
解决方案
对不起,如果这个问题看起来不成熟,但我解决了。我们需要提供以下
- def val = $expectedoutput/Group/Elements/Group/Elements/Group[1]/Elements/Set
Group[0] 将不被接受,因为这里的索引从 1 开始。
推荐阅读
- javascript - 用JS复制Html页面源代码到剪贴板
- java - 如何随机奖励应用程序使用积分
- c# - 使用忽略 _id 的驱动程序更新文档
- perl - 如何从 perl 脚本打印到 CSV 中的特定列
- mysql - 重音敏感全文搜索(MySQL)
- php - 使用 Xdebug 进行调试时启用 OPcache 时未显示局部变量
- python - Pandas:使用空值解析和更新列中的字符串
- javascript - ChartJS 动态折线图在悬停时重影回旧数据
- c - 复制的字符串是否以 '\0' 结尾(第 1.9 节 C 编程语言 K&R2)
- javascript - 是否可以在正则表达式中嵌入代码?