From 187a5c34e0db645c010ef286740570acfe5dabd4 Mon Sep 17 00:00:00 2001 From: Greg Meece Date: Sat, 17 Dec 2016 17:14:08 -0600 Subject: [PATCH] Optional return type of `int` Changed `get_matching_xpath_count` such that returning an integer is an option instead of only a string. See also https://github.com/robotframework/Selenium2Library/issues/715 --- src/Selenium2Library/keywords/_element.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 16f4846e2..af0bfa67c 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -606,9 +606,11 @@ def page_should_not_contain_image(self, locator, message='', loglevel='INFO'): # Public, xpath - def get_matching_xpath_count(self, xpath): + def get_matching_xpath_count(self, xpath, return=str): """Returns number of elements matching `xpath` + The default return type is `str` but can be specified as `int` instead. + One should not use the xpath= prefix for 'xpath'. XPath is assumed. Correct: @@ -620,7 +622,10 @@ def get_matching_xpath_count(self, xpath): `Xpath Should Match X Times`. """ count = len(self._element_find("xpath=" + xpath, False, False)) - return str(count) + if return == 'str': + return str(count) + else: + return count def xpath_should_match_x_times(self, xpath, expected_xpath_count, message='', loglevel='INFO'): """Verifies that the page contains the given number of elements located by the given `xpath`.