Skip to main content

assert_and_parse_html

Parses a string of HTML into a DOM object and raises a test failure with a formatted message if the parsing process encounters an HTMLParseError.

def assert_and_parse_html(
html: string,
user_msg: string,
msg: string
) - > DOM

Attempts to parse a string of HTML into a DOM object, raising a test failure with a formatted message if the HTML is malformed.

Parameters

NameTypeDescription
htmlstringThe raw HTML content to be parsed and validated.
user_msgstringA custom message provided by the user to be included in the failure output if parsing fails.
msgstringThe standard error message or context to be displayed alongside the parsing error.

Returns

TypeDescription
DOMThe parsed document object model representing the provided HTML string.