Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Pattern Matching Callbacks and Dash Testing

Hi folks,

Wondering what to use for HTML selectors for the Browser testing API when we use a pattern-matching callback. I tried a stringified dictionary with no whitespaces as alluded to in the pattern-matching callback documentation, i.e.: '{"index":0,"type":"dynamic-dropdown"}' as a stab in the dark with no luck.

Is there an implementation for this yet?

In the Dash codebase, we’ve got some pattern matching tests with selectors here: https://github.com/plotly/dash/blob/dev/tests/integration/callbacks/test_wildcards.py. Maybe that helps?

1 Like

Thanks, your CSS escape function helped.

I ended up debugging my problem by printing out all of the IDs on the page. The issue was that the ID was formatted as '{"index":1,"type":"filter"}' instead of '{"type":"filter","index":1}' such as how it was created. Do the dictionary keys get sorted alphabetically or something?

edit: just realized i could also inspect the element IDs with dev tools… shows you how much time i spend on the front end :upside_down_face: