Skip to content

Commit 7a8d14a

Browse files
qitaosaaltat
authored andcommitted
add argument for get_list_items (#721)
* add keyword get_list_values * add argument for get_list_items * add test cases for Get List Items new argument * update test cases documents * change test place and change ${False} to False place the test before the Get Selected List Value * change Sample to Example and change ${False} to False * modify argument label=True to value=False modify argument label=True to value=False and the test cases. * Revert "modify argument label=True to value=False" This reverts commit 74049a4. * modify argument label=True to value=False modify argument label=True to value=False and modify the cases.
1 parent 0b545d1 commit 7a8d14a

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Selenium2Library/keywords/_selectelement.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ class _SelectElementKeywords(KeywordGroup):
88

99
# Public
1010

11-
def get_list_items(self, locator):
12-
"""Returns the values in the select list identified by `locator`.
11+
def get_list_items(self, locator, value=False):
12+
"""Returns the labels or values in the select list identified by `locator`.
1313
1414
Select list keywords work on both lists and combo boxes. Key attributes for
1515
select lists are `id` and `name`. See `introduction` for details about
1616
locating elements.
17+
18+
Example:
19+
| ${labels1} = | Get List Items | xpath=//h1 |
20+
| ${labels2} = | Get List Items | xpath=//h1 | value=${False} |
21+
| ${values} = | Get List Items | xpath=//h1 | value=True |
22+
| Should Be Equal | ${labels1} | ${labels2} |
1723
"""
1824
select, options = self._get_select_list_options(locator)
19-
return self._get_labels_for_options(options)
25+
if value:
26+
return self._get_values_for_options(options)
27+
else:
28+
return self._get_labels_for_options(options)
2029

2130
def get_selected_list_label(self, locator):
2231
"""Returns the visible label of the selected element from the select list identified by `locator`.

test/acceptance/keywords/lists.robot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ Get List Items From Multi-Select List
1717
${expected}= Create List Males Females Others
1818
Should Be Equal ${items} ${expected}
1919

20+
Get List Values From Single-Select List
21+
[Documentation] Get List Values From Single-Select List
22+
${values}= Get List Items preferred_channel value=${True}
23+
${expected}= Create List email phone directmail
24+
Should Be Equal ${values} ${expected}
25+
26+
Get List Values From Multi-Select List
27+
[Documentation] Get List Values From Multi-Select List
28+
${values}= Get List Items interests value=True
29+
${expected}= Create List males females others
30+
Should Be Equal ${values} ${expected}
31+
2032
Get Selected List Value
2133
[Documentation] Get Selected List Value
2234
${selected}= Get Selected List Value preferred_channel

0 commit comments

Comments
 (0)