Access app errors in pytest

Hello! My team and I sometimes have issues where we deploy an Streamlit app, and when we open it in Azure, it immediately gives a red error box with some error message. We would like to write tests to avoid this issue. To me the simplest (but likely not the best) way to test this would be to have a test which runs streamlit run and returns any error that occurs. Is there any way to do such a thing?

Our apps usually work just fine locally when we do streamlit run, but sometime we make many smaller changes and forget to build and test in Docker before deploying. A simple way of testing these apps would be greatly beneficial. I couldn’t find anything on this in the docs, and only found a seemingly complex testing tutorial shown here.

Thanks a lot for all your great work! Really enjoy using Streamlit.

Hi @EspenBkk -

I wrote that blog post about testing Streamlit apps using SeleniumBase :slight_smile:

In the blog post, it mostly focuses on visual testing, but in the example repo, there are lines like the following:

You can use the SeleniumBase package to test for various elements existing on the page, and depending on what you’re testing, you could test for the presence of the Streamlit warning messages, errors, etc.


1 Like