如何在 JMeter 中通过 XPath Extractor 从响应中提取属性?
我需要获取属性。通过 JMeter 从 html 获取值 componentId
和 interactionstate
,我尝试使用 XPath 提取器,但我做不到。
<html>
<body>
...
<form ...>
<form class="UIForm" id="UINavigationComposer" action="/portal/intranet/home?portal:componentId=d934d0f3-d465-4c1d-880a-45f54b3c48e2&interactionstate=JBPNS_rO0ABXcwAAt1aWNvbXBvbmVudAAAAAEAFFVJTmF2aWdhdGlvbkNvbXBvc2VyAAdfX0VPRl9f&portal:type=action" method="post">
<form ...>
...
</body>
</html>
我尝试使用 xpath 查询:
/html/body/form@[id=UINavigationComposer]/@action
但出现错误:
断言失败消息:/html/body/form@[id=UINavigationComposer]; =>对实体“portal:action”的引用必须以“;”结尾分隔符。
I need get attr. values componentId
and interactionstate
from html via JMeter, i try with XPath extractor but I can`t do that.
<html>
<body>
...
<form ...>
<form class="UIForm" id="UINavigationComposer" action="/portal/intranet/home?portal:componentId=d934d0f3-d465-4c1d-880a-45f54b3c48e2&interactionstate=JBPNS_rO0ABXcwAAt1aWNvbXBvbmVudAAAAAEAFFVJTmF2aWdhdGlvbkNvbXBvc2VyAAdfX0VPRl9f&portal:type=action" method="post">
<form ...>
...
</body>
</html>
I try to use xpath query:
/html/body/form@[id=UINavigationComposer]/@action
but obtain error:
Assertion failure message: /html/body/form@[id=UINavigationComposer];
=> The reference to entity "portal:action" must end with the ';' delimiter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的 xpath 查询有点失误。
将 @ 放在 id 属性附近,如下所示
或使用类似的内容:
因此,第一步 - 提取完整的操作值并将其存储在单独的 jmeter 变量中(例如 ACTION_TEST) ,使用 RegEx 或 Xpath Extractor。
第二步 - 从此变量中提取 componentId 和交互状态的值。
jmeter 2.5(自 2.3.2 起)中的正则表达式提取器具有选项“应用于... Jmeter 变量”。
您可以添加 2 个额外的正则表达式提取器,每个正则表达式提取器在“应用到... Jmeter 变量”选项中使用 ${ACTION_TEST} 和相应的查询:
希望这会起作用。
I think you have a little lapse in your xpath query.
Put @ near the id attribute like below
or use something like this:
So, the first step - to extract full action value and store it in separate jmeter variable (e.g. ACTION_TEST), using either RegEx or Xpath Extractor.
The second step - to extract from this variable values for componentId and interactionstate.
RegEx Extractor in jmeter 2.5 (since 2.3.2, afair) has option "Apply to ... Jmeter Variable".
You can add 2 additional RegEx Extractors each with ${ACTION_TEST} in "Apply to ... Jmeter Variable" option and correcponding queries:
Hope this will work.