From a68e9f0711d74cef872d90ea5de8c385e685960f Mon Sep 17 00:00:00 2001 From: Anil Kumar Reddy Gaddam Date: Mon, 14 Apr 2014 22:39:08 +0530 Subject: [PATCH 1/4] Update _waiting.py added a wait until element is not visible keyword --- src/Selenium2Library/keywords/_waiting.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Selenium2Library/keywords/_waiting.py b/src/Selenium2Library/keywords/_waiting.py index 1c51ad9b1..06893eeaa 100644 --- a/src/Selenium2Library/keywords/_waiting.py +++ b/src/Selenium2Library/keywords/_waiting.py @@ -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): From 482d837d62f27fa996781ef175c92441936bac64 Mon Sep 17 00:00:00 2001 From: Anil Kumar Reddy Gaddam Date: Mon, 19 May 2014 00:10:29 +0530 Subject: [PATCH 2/4] added a highlight element keyword Added a Highlight Element Keyword which highlights elements --- src/Selenium2Library/keywords/_element.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 9db21ab2d..f940f7ec6 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -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) From d6052a9d6d5179e2d1e180472bcbc166420df56c Mon Sep 17 00:00:00 2001 From: Anil Kumar Reddy Gaddam Date: Mon, 19 May 2014 09:19:03 +0530 Subject: [PATCH 3/4] added test for Keyword Highlight Element added test for Keyword Highlight Element --- test/acceptance/keywords/elements.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/acceptance/keywords/elements.txt b/test/acceptance/keywords/elements.txt index f6b4d2029..d907b1a7b 100644 --- a/test/acceptance/keywords/elements.txt +++ b/test/acceptance/keywords/elements.txt @@ -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"] From ee571b2412b68f913e6fdfb94d3066e06c2bfde2 Mon Sep 17 00:00:00 2001 From: Anil Kumar Reddy Gaddam Date: Mon, 19 May 2014 09:35:05 +0530 Subject: [PATCH 4/4] Update Selenium2Library.html updated Selenium2Library.html with new keywords --- doc/Selenium2Library.html | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/Selenium2Library.html b/doc/Selenium2Library.html index 529f3da4b..92ff09d37 100644 --- a/doc/Selenium2Library.html +++ b/doc/Selenium2Library.html @@ -5,7 +5,7 @@ - +