You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test should fail because the contents of the #my-div div are never equal to None or "None".
Actual behavior
The test passes.
Explanation
This happens because wait_for_text_to_equal checks not only the text content of the element, but also the value of the value attribute. (see here).
If value is not defined we get a value of None, which is then converted to a string and therefore matches the string "None".
So dash_duo.wait_for_text_to_equal("#my-div", "None")always succeeds unless the target element has a defined value.
Proposed solutions
IMO the cleanest solution would be to modify wait_for_text_to_equal to check only the element's text, and add a new function wait_for_value_to_equal which checks the value (or a generalized wait_for_attr_to_equal function). This would break backwards compatibility.
Alternatively we could have wait_for_text_to_equal ignore value if value is not defined, or issue a warning when used with the text "None".
The text was updated successfully, but these errors were encountered:
That way, the overall functionality of wait_for_text_to_equal doesn't change (except for the "None" case). The only downside is that it would pass if you use dash_duo.wait_for_text_to_equal("#my-div", None, timeout=4), but I don't know how often that would come up.
There is also an issue with wait_for_contains_text. The test
Describe your context
pip list | grep dash
belowDescribe the bug
When
wait_for_text_to_equal
is used to wait for the text"None"
, the function will often succeed even when you would reasonably expect it to fail.I think this is part of the reason why the regression in #2733 wasn't caught by the tests.
This behavior is demonstrated by the following test case:
Expected behavior
The test should fail because the contents of the
#my-div
div are never equal toNone
or"None"
.Actual behavior
The test passes.
Explanation
This happens because
wait_for_text_to_equal
checks not only the text content of the element, but also the value of thevalue
attribute. (see here).If
value
is not defined we get a value ofNone
, which is then converted to a string and therefore matches the string"None"
.So
dash_duo.wait_for_text_to_equal("#my-div", "None")
always succeeds unless the target element has a definedvalue
.Proposed solutions
IMO the cleanest solution would be to modify
wait_for_text_to_equal
to check only the element's text, and add a new functionwait_for_value_to_equal
which checks the value (or a generalizedwait_for_attr_to_equal
function). This would break backwards compatibility.Alternatively we could have
wait_for_text_to_equal
ignorevalue
if value is not defined, or issue a warning when used with the text"None"
.The text was updated successfully, but these errors were encountered: