Table of content

HTML Assertion in JMeter

The HTML Assertion allows the user to check the HTML syntax of the response data using JTidy. It will fail the test in case of an improper HTML syntax response.

The HTML Assertion Parameters are as follow:

  • Name : Descriptive name for this element that is shown in the tree.
  • Doctype: omit, auto, strict or loose
  • Format : HTML, XHTML or XML
  • Errors Only : Only take note of errors?
  • Error Threshold : Number of errors allowed before classing the response as failed Yes
  • Warning Threshold : Number of warnings allowed before classing the response as failed Yes
  • Filename : Name of file to which report is written No.

The Following Example Demonstrates the HTML Assertion

  • Launch JMeter in the system.
  • Add, Thread Group to the Test Plan.
  • Next, Add, HTTP Request Sampler to the thread group and mention the Server and Path details.
  • Next, Add HTML Assertion to the HTTP Request and select the Doctype as Omit and Format as HTML and then set the Error Threshold to 0 and Warning Threshold to 0
  • Now, Add View Result Tree and Assertion Result Listener to the Thread Group.
  • Save and Run the Test Plan.
  • After execution, if you check the Assertion Result which is as below.
  • What I was expecting is 0 errors and 0 warnings in the HTML report but the output is showing as 0 Errors and 36 warnings.
  • You can give Error Threshold as 5 and warning Threshold as 38 and give some text file address in your folder as below.
  • I am going to create an HTMLResult.txt file in my project folder.
  • Now click on the Bowse and Add the HTMLResult file into the JMeter, if any errors and warnings will occur then those will be logged into this text file.
  • Save and run the test plan.
  • After the execution, if go and check the HTMLResult.txt file you will find the detailed report of Errors and warnings.
  • This is how the HTML Assertion will be helpful to validate the errors and warnings.
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions