Testing st.data_editor

Hi,

I am running an app, where I have an st.data_editor with a checkbox column.

When the user selects a row a lot of new information will pop up below. I am trying to test the functionality with AppTest.

app = AppTest.from_file(“app/pages/2_my_page.py”)
app.run()
df = app.dataframe.values[0]

I can then filter the dataframe as such:
df .loc[0, ‘select’] = True

I tried to reassign it:
app.dataframe.values[0] = df
app.run()

But nothing happens.

Streamlit ‘1.28.0’
Python 3.10

How do I test this?

Thanks,
Mikkel

Can anyone from the Streamlit Team please have a look at this? Thanks!

There are a couple issues here.

To get a dataframe, I think you’d want app.dataframe[0].value. app.dataframe returns a sequence of all dataframes on the page. app.dataframe[0] is then the first dataframe element on the page. Adding .value then obtains the actual pd.DataFrame object.

For all elements, you can’t assign values to the .value property. Widgets have a .set_value() method plus other widget-specific commands. However, st.data_editor is not supported so there aren’t any official ways to manipulate it yet.

The team is working to add more support until all elements are included, but st.data_editor just isn’t there yet. Sorry.

Hi!
Do we already have a way to test st.data_editor?
Thanks!