I’ve been trying to automate the testing of my app with Python Selenium.
The app sits entirely inside a Dash dbc.Accordion.
There are three dbc.AccordionItem elements. Each has a separate “item_id.”
My app takes a culinary recipe as a block of text and returns a nutritional profile,
The code works fine until I need uncollapse the second dbc.AccordionItem. To keep this brief, I cannot figure out how to uncollapse the second tab and click the submit button with Python-Selenium.
I should be able to do it in many ways (via id, class name, link etc…). When I try to inspect the tab bar in the Chrome browser to find the identifying information I need, I find the results confusing.
By the way, I don’t receive any error messages .
Does anyone have any idea how to solve this problem?
If you have the time, you can inspect the html and css by going to this ip address, where its deployed as a Docker Image on Amazon AWS Elastic Container Services. You can type in my username and password.
(I don’t know why I felt the need to have credentials, excepts its a rough draft. Its functional), I just was not ready for people to see it). Thank you for reviewing my question.
Your feedback is much appreciated.
Robert
P.S. I share snippets of the Python-Selenium code below, but I will gladly share the whole thing as requested.
Its not that long - about a page.
1. This is the IP address:
username: robertpfaff
password: adam2326
2. Here is the relevant Selenium code:
# Moving to second tab: edit initial results
# Find second tab in accordion (second tab).
try:
open_tabtwo = WebDriverWait(driver, 10).until(
EC.presence_of_element_located(
(By.ID, "???"))
)
finally:
print("Unable to locate: ", open_tabtwo)
pass
open_tabtwo.click()
3. Here, I will paste the relevant Dash HTML for the second tab:
dbc.AccordionItem( # Step 2: Edit initial results.
[
html.Div("Please edit initial results.",
className="mb-4"),
dash_table.DataTable(
id="nutrients-review-datatable",
columns=[{'id': i, 'name': i} for i in [
"Index", "Amount", "Unit", "Modifier", "Ingredient", "ID", "Grams", "Multiplier"]],
style_cell={'textAlign': 'left', 'padding': '10px', 'fontSize': 14,
'font-family': 'sans-serif', 'fontWeight': 'bold'},
style_header={'backgroundColor': '6eafde', 'fontWeight': 'bold', 'font-size': 14,
'border': '1px solid black', 'align': 'left', 'color': 'black'},
style_data={'color': 'black'},
style_data_conditional=[
{'if': {'row_index': 'odd'}, 'backgroundColor': 'rgb(248,248,248)'}],
data=None,
editable=True,
row_deletable=True,
# tooltip,
hidden_columns=['Index', 'ID',
'Grams', 'Multiplier'],
css=[{"selector": ".show-hide",
"rule": "display: none"}],
sort_action='native',
page_action='native',
page_size=15,
style_table={'height': '500px',
'overflowY': 'auto'},
),
# html.Div([
# dbc.Button("Submit Recipe", id="recipe-textarea-submit-button", style={'margin-bottom': '10px'}, n_clicks=0, outline=True, color='primary'),
# dbc.Spinner(html.Div(id="loading-output1"), spinner_style={"width": "3rem", "height": "3rem"}),
dbc.Button(
"Submit Edits",
id="nutrients-review-datatable-submit-button",
className="me-2",
n_clicks=0,
outline=True, color='primary'
),
dbc.Spinner(html.Div(id="loading-output2"),
spinner_style={"width": "3rem", "height": "3rem"}),
],
title="Step 2: Edit Initial Results",
item_id="acc_datatable",
),