I created a custom component and would like to test it.
First I got
E RuntimeError: Runtime hasn't been created!
Then I found the AppTest
feature of steamlit:
import gdpr_wrapper
from streamlit.testing.v1 import AppTest
def test_gdpr_wrapper():
at = AppTest.from_function(lambda: gdpr_wrapper('foo')).run()
assert not at.exception
main = at.main
assert main is not None
Now I am wondering, how I can acces the element that correspons to my custom component. The at elment seems to provide lists of predefined compoments, for example ‘text’ and ‘markdown’.
My expectation would be, that
a) There is a generic list like ‘element’ or ‘all’. or
b) Streamlit automatically detects new compoment types and creats additonal lists, for example at.gdpr_wrapper
=> Could you please provide such a generic interface for accessing the dom of custom components? Maybe this is already possible with the “SpecialBlock” I get for at.main
?
As a workaround, I could try to use approaches that are not streamlit specific, like selenium or playwright… as discussed in this old post:
However, that does not feel right.