关于HTML5内容的JMeter XPath Extractor

时间:2017-02-10 09:26:16

标签: html5 xpath jmeter

我试图让JMeter在以下XPath中读取预先填充的表单输入值:/html/body/div[1]/div[3]/div[2]/form/table/tbody/tr[2]/td/div[1]/input/@value

因为我只得到ERROR,所以我调查并启用了Tidy(宽容解析器)以及详细程度(不安静;报告错误),我发现了这个:

ERROR - jmeter.util.XPathUtil: TidyException: line 65 column 9 - Error: <nav> is not recognized!
line 95 column 11 - Error: <nav> is not recognized!
InputStream: Doctype given is ""
InputStream: Document content looks like HTML 4.01 Transitional
85 warnings, 2 errors were found!
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.

由于我们是在2017年,该文档当然是用HTML5编写的,而<nav>是一个完全有效的标记。然而,Tidy没有认识到它。我使用JMeter 3.1 r1770033运行最新的Arch Linux系统。

如何在JMeter中为HTML5网站使用XPath?

1 个答案:

答案 0 :(得分:1)

使用Xpath Extractor

//input[@id='title_de']/@value

截图参考: Xpath Extractor配置: enter image description here

查看结果树: enter image description here

使用Regular Expression Extractor

input id="title_de" class="string optional" value="(.*?)"

截图参考: enter image description here

查看结果树(突出显示捕获的值): enter image description here