Skip to content

XPath Assertion

Configure the JMeter XPath Assertion assertions: properties, defaults, and practical usage notes for building reliable load tests.

Difficulty
intermediate
Guide type
reference
Estimated read time
2 min read
Last verified version
Verified JMeter 5.6

Part of the Assertions category. Also documented in context in the full Component Reference.

XPath Assertion

The XPath Assertion tests a document for well formedness, has the option of validating against a DTD, or putting the document through JTidy and testing for an XPath. If that XPath exists, the Assertion is true. Using โ€œ/โ€ will match any well-formed document, and is the default XPath Expression. The assertion also supports boolean expressions, such as โ€œcount(//*error)=2โ€. See http://www.w3.org/TR/xpath for more information on XPath.

Some sample expressions:

  • //title[text()='Text to match'] - matches <title>Text to match</title> anywhere in the response
  • /title[text()='Text to match'] - matches <title>Text to match</title> at root level in the response
NameRequiredDescription
NameNoDescriptive name for this element that is shown in the tree.
Use Tidy (tolerant parser)YesUse Tidy, i.e. be tolerant of XML/HTML errors
QuietIf Tidy is selectedSets the Tidy Quiet flag
Report ErrorsIf Tidy is selectedIf a Tidy error occurs, then set the Assertion accordingly
Show warningsIf Tidy is selectedSets the Tidy showWarnings option
Use NamespacesIf Tidy is not selectedShould namespaces be honoured? (see note below on NAMESPACES)
Validate XMLIf Tidy is not selectedCheck the document against its schema.
Ignore WhitespaceIf Tidy is not selectedIgnore Element Whitespace.
Fetch External DTDsIf Tidy is not selectedIf selected, external DTDs are fetched.
XPath AssertionYesXPath to match in the document.
Invert assertion(will fail if above conditions met)NoTrue if a XPath expression is not matched or returns false
On this page