@mikeypatt wrote:
Hi,
I am trying to write some basic unit tests for a few core components (we have to for my university work.Here is my code. I am trying to select a crime type in a dcc.Dropown using the dash_duo driver. However, it says that it is not a webelement when trying to use select? In the dropdown there is a “Anti-social behaviour” option to select.
Any help would be massively appreciated
def test_crime_type_callback(dash_duo):
app = Dash(__name__) app.layout = html.Div([dcc.Dropdown(id="crime-dropdown",options=[ {"label": i, "value": i} for i in crime_mapping],placeholder="Select a Crime Type",), html.Div(html.Div([1.5, None, "string", html.Div(id="output-1")])),]) call_count = Value("i", 0) @app.callback(Output("output-1", "children"), [Input("crime-dropdown", "value")]) def update_output(selectedCrime): return selectedCrime dash_duo.start_server(app) #dash_duo.wait_for_text_to_equal("#output-1", "initial value") #dash_duo.percy_snapshot(name="simple-callback-1") select = Select(dash_duo.driver.find_element_by_css_selector("#crime-dropdown")) select.select_by_visible_text('Anti-social behaviour') dash_duo.wait_for_text_to_equal("#output-1", "Anti-social behaviour") dash_duo.percy_snapshot(name="simple-callback-2") # an initial call, one for clearing the input # and one for each hello world character assert call_count.value == 1
Posts: 1
Participants: 1