Skip to content

Commit 39bd3d9

Browse files
committed
grouping for value assignment expression, add test
1 parent 98e3a80 commit 39bd3d9

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

dash/testing/wait.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ def __call__(self, driver):
6262
try:
6363
elem = driver.find_element(By.CSS_SELECTOR, self.selector)
6464
logger.debug("contains text {%s} => expected %s", elem.text, self.text)
65-
if value := elem.get_attribute("value") is not None:
65+
if (value := elem.get_attribute("value")) is not None:
6666
return self.text in str(elem.text) or self.text in str(value)
67-
else:
68-
return self.text in str(elem.text)
67+
return self.text in str(elem.text)
6968
except WebDriverException:
7069
return False
7170

@@ -108,10 +107,9 @@ def __call__(self, driver):
108107
try:
109108
elem = self._get_element(driver)
110109
logger.debug("text to equal {%s} => expected %s", elem.text, self.text)
111-
if value := elem.get_attribute("value") is not None:
110+
if (value := elem.get_attribute("value")) is not None:
112111
return str(elem.text) == self.text or str(value) == self.text
113-
else:
114-
return str(elem.text) == self.text
112+
return str(elem.text) == self.text
115113
except WebDriverException:
116114
return False
117115

tests/integration/test_duo.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,18 @@ def test_duo001_wait_for_text_error(dash_duo):
4747
err.value.args[0]
4848
== "text -> none not found inside element within 1.0s, #none not found"
4949
)
50+
51+
52+
def test_duo002_wait_for_text_value(dash_duo):
53+
app = Dash(__name__)
54+
app.layout = html.Div([html.Ol([html.Li("Item", id="value-item", value="100")])])
55+
dash_duo.start_server(app)
56+
57+
dash_duo.wait_for_text_to_equal("#value-item", "100")
58+
with pytest.raises(TimeoutException) as err:
59+
dash_duo.wait_for_contains_text("#value-item", "None", timeout=1.0)
60+
61+
assert (
62+
err.value.args[0]
63+
== "text -> None not found inside element within 1.0s, found: Item"
64+
)

0 commit comments

Comments
 (0)