You don't have to write your own using beautifulsoup. There are test frameworks like https://www.cypress.io/ and https://playwright.dev/ that work great there.
Seems very brittle and may not catch actual regressions browsers introduce.
One addition makes it an order of magnitude more versatile: a way to visualize non-textual information as text in the tests. For example add a data-test-icon attribute which contains the replacement text that should be shown in tests. Another method is to parse the HTML and write custom visualization for some elements, so that you get useful default visualization for at least form elements and such, without having to repeat the data-test-icon attribute every time.
See https://martinfowler.com/articles/tdd-html-templates.html#Bo...