You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhance Get List Items to support returning values or labels #722
The keyword get_list_items docstring wrote it will return the values in the select list. But the result is:
I want to get the option value for "item1","item2","item3", but it returns the labels "first","second","third".
So I checked the keyword get_list_items source code:
`
def get_list_items(self, locator):
"""Returns the values in the select list identified by `locator`.
Select list keywords work on both lists and combo boxes. Key attributes for
select lists are `id` and `name`. See `introduction` for details about
locating elements.
"""
select, options = self._get_select_list_options(locator)
return self._get_labels_for_options(options)
`
It wrote 'returns the values', but it return self._get_labels_for_options(options).
I change the docstring to "Returns the labels", then add a keyword for get_list_values:
`
def get_list_values(self, locator):
"""Returns the values in the select list identified by `locator`.
Select list keywords work on both lists and combo boxes. Key attributes for
select lists are `id` and `name`. See `introduction` for details about
locating elements.
"""
select, options = self._get_select_list_options(locator)
return self._get_values_for_options(options)
Ah, now I understand, thank you from the explanation.
Your need is a valid one. The only thing that I am wondering do we need a new keyword for this or would it be better to have one keyword and decide based on argument what to return. Example:
| ${labels1} = | Get List Items | xpath=//h1 |
| ${labels2} = | Get List Items | xpath=//h1 | label=${True} |
| ${values} = | Get List Items | xpath=//h1 | label=${False} |
| Should Be Equal | ${labels1} | ${labels2} |
There are quite many keywords and I don't like to raise the keyword amount. But I don't feel strongly on the matter, what do you think, or others?
Also the new functionality must be backed up with tests.
It was decided to make configurable to keyword return values or labels based on a new value argument. The keyword default functionality is backwards compatible.
changed the title [-]get_list_items return the labels or values[/-][+]Enhance `Get List Items` to support returning values or labels[/+]on Sep 26, 2017
I think values is better name for the optional argument than value. I'll change it while doing cleanup to list related keywords and their docs in general. I'll also add a note that this argument is new in SL 3.0.
Activity
aaltat commentedon Dec 28, 2016
Ah, now I understand, thank you from the explanation.
Your need is a valid one. The only thing that I am wondering do we need a new keyword for this or would it be better to have one keyword and decide based on argument what to return. Example:
There are quite many keywords and I don't like to raise the keyword amount. But I don't feel strongly on the matter, what do you think, or others?
Also the new functionality must be backed up with tests.
qitaos commentedon Dec 30, 2016
I think add argument is fine too.
qitaos commentedon Dec 30, 2016
@aaltat I made a new commit for add argument and test cases.
aaltat commentedon Dec 30, 2016
Thank you. I am busy other stuff for few days, but next year there should be time to take a look.
[-]get_list_items return the labels not values[/-][+]get_list_items return the labels or values[/+]aaltat commentedon Jan 11, 2017
It was decided to make configurable to keyword return values or labels based on a new
valueargument. The keyword default functionality is backwards compatible.aaltat commentedon Jan 11, 2017
Done in #721
[-]get_list_items return the labels or values[/-][+]Enhance `Get List Items` to support returning values or labels[/+]pekkaklarck commentedon Nov 6, 2017
I think
valuesis better name for the optional argument thanvalue. I'll change it while doing cleanup to list related keywords and their docs in general. I'll also add a note that this argument is new in SL 3.0.Cleanup list keyword code and docs.