JMeter – HTML Assertion

In JMeter script, HTML Assertion is a rarely used assertion component where more stress is given to the correctness of web design and validation of the tags. HTML assertion parses the web page coming in the response using JTidy (which is an HTML syntax checker tool) and then provides output in the form of pass or fail. If the assertion fails then the output shows the number of errors and warnings.

How to add ‘HTML Assertion’?

You can follow the below steps:

  1. Select the ‘Sampler’ element whose HTML response needs to be validated.
  2. Right-click on the node
  3. Hover the cursor on ‘Add’
  4. Hover the cursor on ‘Assertions
  5. Click ‘HTML Assertion’
JMeter - HTML Assertion
Figure 01: JMeter – HTML Assertion

What are the input fields?

‘HTML Assertion’ has the following input fields:

  • Name: To provide the name of the assertion.
  • Comments: To provide arbitrary comments (if any)
  • Tidy Settings: Instruct JMeter to perform given operations like omit (to ignore), auto (as usual), strict (check all the syntaxes) or loose (can ignore child element).
  • Format: The format of the response. The available options are HTML, XHTML and XML.
  • Error Only: Once it is checked then JMeter considers only errors in the syntax and omits the warnings.
  • Error Threshold: To provide the count of errors which can be ignored and considered the request as pass. 
  • Warning Threshold: The number of warnings which can be ignored and considered the request as passed.
  • Write JTidy report to file: Specify the path and name of the file where a report will be written during test execution.  

You may be interested:


2 thoughts on “JMeter – HTML Assertion”

  1. Hi Team,

    I am getting this on Assertion Results Listener.
    How can I fix this?

    HTML Assertion : can’t parse argument number:

  2. Hi Harshal,

    Please use Response Assertion instead of HTML Assertion and validate the content of the page instead of validating the format.

Comments are closed.