Skip to content

Commit ec67658

Browse files
committed
Merge pull request #415 from deiga/patch-2
Adds Wait Until Page Does Not Contain method
2 parents 4efcb9c + 4116379 commit ec67658

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ Release Notes
33

44
1.7 (unreleased)
55
----------------
6+
- Added new keyword 'Wait Until Page Does Not Contain'.
7+
[deiga]
8+
69
- Fixed ‘NoSuchWindowException' issue. Running keyword 'Select Window' after 'Close Window'
710
will trigger this issue if locator has prefix 'name=','title=' or 'url='. Also fixed same
811
issue for keywords 'Get Window Ids', 'Get Window Titles' and 'Get Window Names'.
912
[divfor]
10-
13+
1114
- Corrected error message in new keyword 'Wait Until Element Is Not
1215
Visible' to reflect element being visible instead of not visible.
1316
[joepurdy]

src/Selenium2Library/keywords/_waiting.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,27 @@ def wait_until_page_contains(self, text, timeout=None, error=None):
4545
error = "Text '%s' did not appear in <TIMEOUT>" % text
4646
self._wait_until(timeout, error, self._is_text_present, text)
4747

48+
def wait_until_page_does_not_contain(self, text, timeout=None, error=None):
49+
"""Waits until `text` disappears from current page.
50+
51+
Fails if `timeout` expires before the `text` disappears. See
52+
`introduction` for more information about `timeout` and its
53+
default value.
54+
55+
`error` can be used to override the default error message.
56+
57+
See also `Wait Until Page Contains`, `Wait For Condition`,
58+
`Wait Until Element Is Visible` and BuiltIn keyword `Wait Until
59+
Keyword Succeeds`.
60+
"""
61+
def check_present():
62+
present = self._is_text_present(text)
63+
if not present:
64+
return
65+
else:
66+
return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout))
67+
self._wait_until_no_error(timeout, check_present)
68+
4869
def wait_until_page_contains_element(self, locator, timeout=None, error=None):
4970
"""Waits until element specified with `locator` appears on current page.
5071

test/acceptance/keywords/waiting.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Wait Until Page Contains
1212
Wait Until Page Contains New Content 2 s
1313
Run Keyword And Expect Error Text 'invalid' did not appear in 100 milliseconds Wait Until Page Contains invalid 0.1
1414

15+
Wait Until Page Does Not Contain
16+
Wait Until Page Does Not Contain This is content 2 s
17+
Run Keyword And Expect Error Text 'Inititally hidden' did not disappear in 100 milliseconds Wait Until Page Does Not Contain Inititally hidden 0.1
18+
1519
Wait Until Page Contains Element
1620
[Documentation] Tests also that format characters (e.g. %c) are handled correctly in error messages
1721
Wait Until Page Contains Element new div 2 seconds

0 commit comments

Comments
 (0)