Skip to content
Closed
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
9 changes: 7 additions & 2 deletions src/Selenium2Library/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

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.

Perhaps return_str=True would be better argument definition.

  1. It would not be confused with Python return statement.
  2. Then you could do something like this (in lines 625 - 628):
    return str(count) if return_str else count

"""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:
Expand All @@ -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`.
Expand Down