英文:
How to traverse through XML file and fetch a particular value and pass it on to for each controller
问题
从我的先前回复中,我得到以下的XML:
<?xml version="1.0" encoding="UTF-8"?>
-
<viewList>
-
<view title="107cd5b450594e9ba1e2834b10ccfcb" transaction_id="307288fbcc9948f8ab6596d2a3b336a7" key_testcase="52dc4c0bcdb6413484cab16f43ef9d49" active="true" raw="true">
<testcase id="52dc4c0bcdb6413484cab16f43ef9d49" size="530374"/>
<testcase id="5d7e204dec034bfaa130757a98728816" size="530374"/>
<testcase id="e165b07bea874896be6d2aa81abeac19" size="530374"/>
<testcase id="3ac054f9bbec41f8b39f4fe236e4e358" size="530374"/>
<testcase id="e4c48aee4aa4b588e1c263290722212" size="530374"/>
<testcase id="389cf80bdcb4e27b7fd2cd07fd7464a" size="530374"/>
<testcase id="17cd8be81227463e8ccbfd6b4263b872" size="530374"/>
<testcase id="2d8b3214ae441948edfc472cb654cb" size="530374"/>
<testcase id="610004abc53b45dbb7d075c7c02b1fae" size="530374"/>
<testcase id="121a016bc32e43779a634b7990687312" size="530374"/>
<testcase id="119b1fd4e4334b1a84707e2fd67667b4" size="530374"/>
<testcase id="9253b4da50ff488081e9fd3e93da85c" size="530374"/>
<testcase id="808c3055549c48e2a0e3a95aadd54918" size="530374"/>
</view>
</viewList>
想要检索所有测试用例并将其传递给for each控制器。如何做?
英文:
From my previous response I am getting the following XML,
<?xml version="1.0" encoding="UTF-8"?>
-
<viewList>
-
<view title="107cd5b450594e9ba1e2834b10ccfcb" transaction_id="307288fbcc9948f8ab6596d2a3b336a7" key_testcase="52dc4c0bcdb6413484cab16f43ef9d49" active="true" raw="true">
<testcase id="52dc4c0bcdb6413484cab16f43ef9d49" size="530374"/>
<testcase id="5d7e204dec034bfaa130757a98728816" size="530374"/>
<testcase id="e165b07bea874896be6d2aa81abeac19" size="530374"/>
<testcase id="3ac054f9bbec41f8b39f4fe236e4e358" size="530374"/>
<testcase id="e4c48aee4aa4b588e1c263290722212" size="530374"/>
<testcase id="389cf80bdcb4e27b7fd2cd07fd7464a" size="530374"/>
<testcase id="17cd8be81227463e8ccbfd6b4263b872" size="530374"/>
<testcase id="2d8b3214ae441948edfc472cb654cb" size="530374"/>
<testcase id="610004abc53b45dbb7d075c7c02b1fae" size="530374"/>
<testcase id="121a016bc32e43779a634b7990687312" size="530374"/>
<testcase id="119b1fd4e4334b1a84707e2fd67667b4" size="530374"/>
<testcase id="9253b4da50ff488081e9fd3e93da85c" size="530374"/>
<testcase id="808c3055549c48e2a0e3a95aadd54918" size="530374"/>
</view>
</viewList>
Want to retrieve all test case it and pass it to for each controller. How to do it ?
答案1
得分: 1
你可以使用XPath Extractor来完成这个操作。
-
将其添加为返回上述XML的请求的子节点,并配置如下:
-
然后添加ForEach Controller,并进行如下设置:
-
就这样,XPath Extractor将获取所有测试用例的ID,ForEach Controller将迭代所有这些ID,您可以在ForEach Controller中引用当前测试用例的ID,如
${testcase_id}
所示:
更多信息:在JMeter中使用XPath Extractor
英文:
You can do it using XPath Extractor
-
Add it as a child of the request which returns the above XML and configure as follows:
-
Then add ForEach Controller and set it up like:
-
That's it, the XPath Extractor will fetch all testcases ids and ForEach Controller will iterate all of them, you will be able to refer the current testcase id inside the ForEach Controller as
${testcase_id}
where required:
More information: Using the XPath Extractor in JMeter
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论