Permalink
Browse files

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.
  • Loading branch information...
1 parent 0b545d1 commit 7a8d14ae5e32781c96ff071c3a7b34d7322be78f @qitaos qitaos committed with aaltat Jan 11, 2017
Showing with 24 additions and 3 deletions.
  1. +12 −3 src/Selenium2Library/keywords/_selectelement.py
  2. +12 −0 test/acceptance/keywords/lists.robot
@@ -8,15 +8,24 @@ class _SelectElementKeywords(KeywordGroup):
# Public
- def get_list_items(self, locator):
- """Returns the values in the select list identified by `locator`.
+ def get_list_items(self, locator, value=False):
+ """Returns the labels or 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.
+
+ Example:
+ | ${labels1} = | Get List Items | xpath=//h1 |
+ | ${labels2} = | Get List Items | xpath=//h1 | value=${False} |
+ | ${values} = | Get List Items | xpath=//h1 | value=True |
+ | Should Be Equal | ${labels1} | ${labels2} |
"""
select, options = self._get_select_list_options(locator)
- return self._get_labels_for_options(options)
+ if value:
+ return self._get_values_for_options(options)
+ else:
+ return self._get_labels_for_options(options)
def get_selected_list_label(self, locator):
"""Returns the visible label of the selected element from the select list identified by `locator`.
@@ -17,6 +17,18 @@ Get List Items From Multi-Select List
${expected}= Create List Males Females Others
Should Be Equal ${items} ${expected}
+Get List Values From Single-Select List
+ [Documentation] Get List Values From Single-Select List
+ ${values}= Get List Items preferred_channel value=${True}
+ ${expected}= Create List email phone directmail
+ Should Be Equal ${values} ${expected}
+
+Get List Values From Multi-Select List
+ [Documentation] Get List Values From Multi-Select List
+ ${values}= Get List Items interests value=True
+ ${expected}= Create List males females others
+ Should Be Equal ${values} ${expected}
+
Get Selected List Value
[Documentation] Get Selected List Value
${selected}= Get Selected List Value preferred_channel

0 comments on commit 7a8d14a

Please sign in to comment.