import streamlit as st
col1, col = st.columns((1, 1))
with st.container():
col1.title("My App")
and I am trying to use AppTest to test that st.title is equal to âMy Appâ but I canât seem to access it with my test file:
from streamlit.testing.v1 import AppTest
at = AppTest.from_file("graph.py", default_timeout=75).run()
def test_headers():
assert "My App" in at.container[0].columns[0].title[0].value
I canât seem to find it in the docs on how to access the container. I know there is this section, retrieve containers, but, at least to me, itâs not super clear how to access elements in a container. An example like this in the docs would be nice. The cheatsheet for layouts and containers doesnât to have an example for containers except for sidebar, columns, and tabs.
@Goyo either way, I canât seem to get pytest to pass the test so I am still not sure what I am doing wrong and what I need to do.
This passes:
test file:
from streamlit.testing.v1 import AppTest
at = AppTest.from_file("graph.py", default_timeout=75).run()
def test_headers():
assert "My App" in at.columns[0].title[0].value
streamlit file:
import streamlit as st
col1, col2 = st.columns((9, 1))
col1.title("My App")
This fails:
but the moment I put the streamlit file code in a container, it fails:
import streamlit as st
with st.container():
col1, col2 = st.columns((9, 1))
col1.title("My App")
so it doesnât seem to that they are accessible in at.columns like you mentioned unless Iâm missing something.