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:
- Select the ‘Sampler’ element whose HTML response needs to be validated.
- Right-click on the node
- Hover the cursor on ‘Add’
- Hover the cursor on ‘Assertions‘
- Click ‘HTML Assertion’
What are the input fields of ‘HTML Assertion’?
‘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 operation 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 omit 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 pass.
- Write JTidy report to file: Specify the path and name of the file where a report will be written during test execution.