Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Selenium2Library/keywords/_waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ def wait_until_page_contains_element(self, locator, timeout=None, error=None):
error = "Element '%s' did not appear in <TIMEOUT>" % locator
self._wait_until(timeout, error, self._is_element_present, locator)

def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None):
"""Waits until element specified with `locator` disappears from current page.

Fails if `timeout` expires before the element disappears. See
`introduction` for more information about `timeout` and its
default value.

`error` can be used to override the default error message.

See also `Wait Until Page Contains`, `Wait For Condition`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Wait Until Page Contains Element?

`Wait Until Element Is Visible` and BuiltIn keyword `Wait Until
Keyword Succeeds`.
"""
def check_present():
present = self._is_element_present(locator)
if not present:
return
else:
return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout))
self._wait_until_no_error(timeout, check_present)

def wait_until_element_is_visible(self, locator, timeout=None, error=None):
"""Waits until element specified with `locator` is visible.

Expand Down
5 changes: 5 additions & 0 deletions test/acceptance/keywords/waiting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Wait Until Page Contains Element
Wait Until Page Contains Element new div 2 seconds
Run Keyword And Expect Error Element '%cnon-existent' did not appear in 100 milliseconds Wait Until Page Contains Element %cnon-existent 0.1 seconds

Wait Until Page Does Not Contain Element
[Documentation] Tests also that format characters (e.g. %c) are handled correctly in error messages
Wait Until Page Does Not Contain Element not_present 2 seconds
Run Keyword And Expect Error Element 'content' did not disappear in 100 milliseconds Wait Until Page Does Not Contain Element content 0.1 seconds

Wait Until Element Is Visible
Run Keyword And Expect Error Element 'hidden' was not visible in 100 milliseconds Wait Until Element Is Visible hidden 0.1
Wait Until Element Is Visible hidden 2 s
Expand Down
10 changes: 8 additions & 2 deletions test/resources/html/javascript/delayed_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<script type="text/javascript">
function modifyAfterDelay() {
setTimeout('addElement()', 1000)
setTimeout('removeElement()', 1000)
setTimeout('changeContent()', 1000)
setTimeout('changeTitle()', 1000)
setTimeout('unhideContent()', 1000)
Expand All @@ -16,7 +17,11 @@
div.innerHTML = 'New Element'
document.getElementById("container").appendChild(div)
}


function removeElement() {
document.getElementById("not_present").remove()
}

function changeTitle() {
document.title = "Changed"
document.bgColor = '#FF00FF'
Expand All @@ -38,7 +43,8 @@
<body onload="modifyAfterDelay()">
<div id="content">This is content</div>
<div id="container"></div>
<div id="not_present">Element that should disappear</div>
<div id="hidden" style="display:none;">Inititally hidden content</div>
<button id="disabled" disabled>Inititally disabled content</button>
</body>
</html>
</html>