I am using Playwright to automate the testing of a Streamlit app, both in Python. Part of the app’s core functionality is that it first returns a dataset based on initial user input, the end user then selects their desired row from the results, and the rest of the app functionality is based on that selection, so refactoring to avoid this problem is not an option. For this testing, I would like to select the checkbox in the first row of the results.
In my Streamlit app, the code to make the data editor is roughly,
my_data_editor = st.data_editor(
data=my_df,
column_order=[
"SELECT",
"COLUMN_A",
"COLUMN_B",
],
column_config={
"SELECT": st.column_config.CheckboxColumn(),
},
hide_index=True,
)
using Chromium to help me generate Playwright code, the most I can get is that clicking on the data editor yields page.locator(".dvn-scroller").click()
, which is simply the data editor as a whole. I cannot get it to let me click on a particular component of the data editor. In particular, I cannot check the box using Chromium.
I have tried running page.locator(".dvn-scroller").first.locator("tr >> nth=0 >> td:nth-child(0) >> input[type='checkbox']").check()
, but that was unsuccessful.
What can I do to get Playwright to check the checkbox in the SELECT
column in the first row?
Nick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1