Feature request: LiveServerTestCase to store HTML source and image of the website when test case fails

32 views
Skip to first unread message

Kazooie

unread,
Aug 14, 2022, 2:58:32 PM8/14/22
to Django developers (Contributions to Django itself)
Hey,

Would it be possible to add a feature to LiveServerTestCase class to take a screenshot of the web page and store the HTML somewhere in case of test failure? I had to recently do this for one of my projects. This can be helpful when debugging stuff for example when test fails in CI pipeline.

This is something Rails does by default (https://guides.rubyonrails.org/testing.html#screenshot-helper) and it would be good to have this in Django as well, so users don't need to manually code this for every project they have. Of course this would need to also expect some default driver to be used like Chrome in Rails case.

What are your thoughts? I'd be able to take a stab at this if this is something that is considered useful.

Best regards,

Mauri Mustonen

Adam Johnson

unread,
Aug 14, 2022, 5:11:26 PM8/14/22
to Django developers (Contributions to Django itself)
Hi Kazooie

LiveServerTestCase is a bit more lightweight than tools for using specific drivers. It doesn't tie into Selenium, or Playwright, or any other particular web browser library. Therefore I don't think there's going to be any way for LiveServerTestCase to know what the current page is, in order to save its contents.

I think, at this time, it would be interesting to see a third party package that implements what you're suggesting, for a particular web browser library. This way you can be more specific about what you support, and how.

Thanks,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/0caab9b2-4dcc-4082-9893-dd6c78c3f53cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages