Adds possibility to define get matching xpath count kw return type#735
Merged
aaltat merged 2 commits intorobotframework:masterfrom Jan 24, 2017
aaltat:fix_get_matching_xpath_count_return_type
Merged
Adds possibility to define get matching xpath count kw return type#735aaltat merged 2 commits intorobotframework:masterfrom aaltat:fix_get_matching_xpath_count_return_type
aaltat merged 2 commits intorobotframework:masterfrom
aaltat:fix_get_matching_xpath_count_return_type
Conversation
This was referenced Jan 22, 2017
| def get_matching_xpath_count(self, xpath, return_str=True): | ||
| """Returns number of elements matching `xpath` | ||
|
|
||
| The default return type is `str`but it can changed to `int` by setting |
Contributor
Author
There was a problem hiding this comment.
Good catch, I will fix it.
| """ | ||
| count = len(self._element_find("xpath=" + xpath, False, False)) | ||
| return str(count) | ||
| return str(count) if return_str else count |
There was a problem hiding this comment.
IMHO we should follow DateTime's lead and use a util method to make sure that str('false') is treated as False, etc.
from robot.utils import is_truthy
...
return str(count) if is_truthy(return_str) else count
Contributor
Author
There was a problem hiding this comment.
I agree, but would like to do it same time for all the keywords using booleans. There is #719 for this problem.
| Should Be Equal ${count} 19 | ||
| Should Be String ${count} | ||
| ${count}= Get Matching XPath Count //a ${False} | ||
| Should Be Equal As Numbers ${count} 19 |
There was a problem hiding this comment.
I think you can just do a direct comparison to an int here...
Should Be Equal ${count} ${19}
Contributor
Author
There was a problem hiding this comment.
Good point, I will fix it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #715