Skip to content

Commit 0ee047e

Browse files
committed
more test fixing - including @chriddyp's updates to wait_for_*
1 parent 681e8c5 commit 0ee047e

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

Diff for: tests/IntegrationTests.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,25 @@ def percy_snapshot(cls, name=''):
2121
name=snapshot_name
2222
)
2323

24-
def wait_for_element_by_css_selector(self, selector):
25-
return WebDriverWait(self.driver, TIMEOUT).until(
26-
EC.presence_of_element_located((By.CSS_SELECTOR, selector))
24+
def wait_for_element_by_css_selector(self, selector, timeout=TIMEOUT):
25+
return WebDriverWait(self.driver, timeout).until(
26+
EC.presence_of_element_located((By.CSS_SELECTOR, selector)),
27+
'Could not find element with selector "{}"'.format(selector)
2728
)
2829

29-
def wait_for_text_to_equal(self, selector, assertion_text):
30-
return WebDriverWait(self.driver, TIMEOUT).until(
31-
EC.text_to_be_present_in_element((By.CSS_SELECTOR, selector),
32-
assertion_text)
30+
def wait_for_text_to_equal(self, selector, assertion_text, timeout=TIMEOUT):
31+
self.wait_for_element_by_css_selector(selector)
32+
WebDriverWait(self.driver, timeout).until(
33+
lambda *args: (
34+
(str(self.wait_for_element_by_css_selector(selector).text)
35+
== assertion_text) or
36+
(str(self.wait_for_element_by_css_selector(selector).get_attribute('value'))
37+
== assertion_text)
38+
),
39+
"Element '{}' text was supposed to equal '{}' but it didn't".format(
40+
selector,
41+
assertion_text
42+
)
3343
)
3444

3545
@classmethod

Diff for: tests/test_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ def test_multi_output_no_update(self):
679679
def show_clicks(n):
680680
# partial or complete cancelation of updates via no_update
681681
return [
682-
no_update if n > 4 else n,
683-
no_update if n > 2 else n,
682+
no_update if n and n > 4 else n,
683+
no_update if n and n > 2 else n,
684684
no_update
685685
]
686686

0 commit comments

Comments
 (0)