splinter icon indicating copy to clipboard operation
splinter copied to clipboard

tests: fix for lxml 6

Open thunze opened this issue 1 month ago • 2 comments

lxml 6 doesn't find a <body> tag via the XPath expression //body anymore when the parsed HTML doesn't contain any tags at all. This currently causes the following tests to fail when lxml 6 is used:

Version 0.21.0:

tests/test_djangoclient.py::DjangoClientDriverTest::test_is_text_present_and_should_wait_time
tests/test_djangoclient.py::DjangoClientDriverTestWithCustomHeaders::test_create_a_phantomjs_with_custom_headers
tests/test_flaskclient.py::FlaskClientDriverTest::test_is_text_present_and_should_wait_time
tests/test_flaskclient.py::FlaskClientDriverTestWithCustomHeaders::test_create_a_flask_client_with_custom_headers
tests/test_zopetestbrowser.py::ZopeTestBrowserDriverTest::test_is_text_present_and_should_wait_time

master at the time of writing (https://github.com/cobrateam/splinter/commit/861539107381e848f63c350189360520c300ced9):

tests/tests_django/test_custom_headers.py::test_create_a_django_client_with_custom_headers
tests/test_all_drivers/test_is_text_present.py::test_is_text_present_and_should_wait_time

See https://hydra.nixos.org/build/314264704/nixlog/1 for logs of the test failures. Note that these logs were obtained by running the test suite of version 0.21.0 and the tests have apparently been restructured since then. I'm pretty sure the underlying test failures are the same though.

This PR fixes these test failures by wrapping fake web server responses that currently don't have a <body> tag with <html><body>...</body></html>.

thunze avatar Nov 29 '25 22:11 thunze

@fsouza Sure thing!

I don't think the CI failures are related to this change, can you confirm this?

thunze avatar Dec 07 '25 00:12 thunze

yeah I think that's a flaky test, let me see if a retry will turn it green

fsouza avatar Dec 07 '25 05:12 fsouza