Skip to content
Closed
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
17 changes: 14 additions & 3 deletions doc/Selenium2Library.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/Selenium2Library/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,17 @@ def _page_should_not_contain_element(self, locator, tag, message, loglevel):
raise AssertionError(message)
self._info("Current page does not contain %s '%s'."
% (element_name, locator))

def highlight_element(self, locator):
"""Highlights (blinks) an element identified by `locator`."""
element = self._element_find(locator, True, True)
script = """
element = arguments[0];
original_style = element.getAttribute('style');
element.setAttribute('style', original_style + "; background: yellow;");
setTimeout(function(){
element.setAttribute('style', original_style);
}, 300);
"""
self._current_browser().execute_script(script, element)

23 changes: 23 additions & 0 deletions src/Selenium2Library/keywords/_waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,29 @@ def check_visibility():
return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout))
self._wait_until_no_error(timeout, check_visibility)

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

Fails if `timeout` expires before the element is hidden. 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 Until Page Contains
Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword
Succeeds`.
"""
def check_hidden():
visible = self._is_visible(locator)
if not visible:
return
elif visible is None:
return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout))
else:
return error or "Element '%s' was not hidden in %s" % (locator, self._format_timeout(timeout))
self._wait_until_no_error(timeout, check_hidden)

# Private

def _wait_until(self, timeout, error, function, *args):
Expand Down
5 changes: 4 additions & 1 deletion test/acceptance/keywords/elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ Get Vertical Position
${pos}= Get Vertical Position link=Link
Should Be True ${pos} > ${0}
Run Keyword And Expect Error Could not determine position for 'non-existent' Get Horizontal Position non-existent


Highlight Element
Highlight Element link=Link
Highlight Element xpath=//div[@id="first_div"]