-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expose stringify_id
at top level and add optional parameter escape_css
#1637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
stringify_id
at top level and add optional parameter escape_css
b7d8305
to
0c621fc
Compare
0c621fc
to
e4df8ce
Compare
|
||
dash_duo.start_server(app) | ||
|
||
assert dash_duo.wait_for_element_by_id(dash.stringify_id(id, escape_css=True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an easy possibility of extending
Lines 277 to 288 in e8ac949
def wait_for_element_by_id(self, element_id, timeout=None): | |
"""Explicit wait until the element is present, timeout if not set, | |
equals to the fixture's `wait_timeout` shortcut to `WebDriverWait` with | |
`EC.presence_of_element_located`.""" | |
return self._wait_for( | |
EC.presence_of_element_located, | |
((By.ID, element_id),), | |
timeout, | |
"timeout {}s => waiting for element id {}".format( | |
timeout if timeout else self._wait_timeout, element_id | |
), | |
) |
to check if input
element_id
is dict, and then do dash.stringify_id(element_id, escape_css=True)
for the user in the wait_for_element_by_id
function.
The user's test line here
assert dash_duo.wait_for_element_by_id(dash.stringify_id(id, escape_css=True))
then becomes
assert dash_duo.wait_for_element_by_id(id)
both in the case with string IDs, and dictionary IDs (when you use pattern-matching callbacks).
Not sure if that is too magical 🔮 or a nice and easy to understand convenience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea with extending the testing utilities, I think that is where most cases would be for escaping.
hi @T4rk1n - is this one still relevant or has it gone stale? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry this PR fell under the cracks, I think this is still good, just need to update with dev branch which include new code for stringify_id
if isinstance(id_, dict): | ||
return json.dumps(id_, sort_keys=True, separators=(",", ":")) | ||
return id_ | ||
def css_escape(stringified_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe rename to escape_css_id
.
@@ -3,6 +3,7 @@ | |||
# must come before any other imports. | |||
__plotly_dash = True | |||
from .dash import Dash, no_update # noqa: F401,E402 | |||
from ._utils import stringify_id # noqa: F401,E402 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also expose css_escape
|
||
dash_duo.start_server(app) | ||
|
||
assert dash_duo.wait_for_element_by_id(dash.stringify_id(id, escape_css=True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea with extending the testing utilities, I think that is where most cases would be for escaping.
Closes #1625 (except the
dash-docs
part - but I can take that after review and if accepted).Contributor Checklist
stringify_id
at top level.css_escape
function.optionals
CHANGELOG.md