From 51e748b45a35bae39e3ab899db2527c84b2b9c52 Mon Sep 17 00:00:00 2001 From: Jacky Qi Date: Tue, 27 Dec 2016 12:27:52 +0800 Subject: [PATCH 1/9] add keyword get_list_values --- src/Selenium2Library/keywords/_selectelement.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 4c4e14edf..58fe26b23 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -9,7 +9,7 @@ class _SelectElementKeywords(KeywordGroup): # Public def get_list_items(self, locator): - """Returns the values in the select list identified by `locator`. + """Returns the labels 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 @@ -18,6 +18,16 @@ def get_list_items(self, locator): select, options = self._get_select_list_options(locator) return self._get_labels_for_options(options) + 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) + def get_selected_list_label(self, locator): """Returns the visible label of the selected element from the select list identified by `locator`. From 1aee06603c45f3a48a38d986ab4df2d5f4a52abf Mon Sep 17 00:00:00 2001 From: qitao Date: Fri, 30 Dec 2016 15:48:44 +0800 Subject: [PATCH 2/9] add argument for get_list_items --- .../keywords/_selectelement.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 58fe26b23..48dcbaab3 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -8,25 +8,24 @@ class _SelectElementKeywords(KeywordGroup): # Public - def get_list_items(self, locator): - """Returns the labels in the select list identified by `locator`. + def get_list_items(self, locator, label=True): + """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. + + Sample: + | ${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} | """ select, options = self._get_select_list_options(locator) - return self._get_labels_for_options(options) - - 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) + if label: + return self._get_labels_for_options(options) + else: + return self._get_values_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`. From d120bf511fa7bb3b3fb7f96c36e0e8d1a8c5f2e2 Mon Sep 17 00:00:00 2001 From: qitao Date: Fri, 30 Dec 2016 16:17:26 +0800 Subject: [PATCH 3/9] add test cases for Get List Items new argument --- test/acceptance/keywords/lists.robot | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index 6f6776985..39888da00 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -148,6 +148,18 @@ List Should Have No Selections ... List 'interests' should have had no selection (selection was [ Males | Females | Others ]) ... List Should Have No Selections interests +Get List Values From Single-Select List + [Documentation] Get List Items From Single-Select List + ${values}= Get List Items preferred_channel ${False} + ${expected}= Create List email phone directmail + Should Be Equal ${values} ${expected} + +Get List Values From Multi-Select List + [Documentation] Get List Items From Multi-Select List + ${values}= Get List Items interests ${False} + ${expected}= Create List males females others + Should Be Equal ${values} ${expected} + *** Keywords *** Unselect And Verify Selection [Documentation] Unselect And Verify Selection From f84682e945e18d576c12d9ec1a2e9dcbc217a8d4 Mon Sep 17 00:00:00 2001 From: qitao Date: Fri, 30 Dec 2016 16:24:23 +0800 Subject: [PATCH 4/9] update test cases documents --- test/acceptance/keywords/lists.robot | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index 39888da00..dff0bf901 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -149,14 +149,14 @@ List Should Have No Selections ... List Should Have No Selections interests Get List Values From Single-Select List - [Documentation] Get List Items From Single-Select List - ${values}= Get List Items preferred_channel ${False} + [Documentation] Get List Values From Single-Select List + ${values}= Get List Items preferred_channel label=${False} ${expected}= Create List email phone directmail Should Be Equal ${values} ${expected} Get List Values From Multi-Select List - [Documentation] Get List Items From Multi-Select List - ${values}= Get List Items interests ${False} + [Documentation] Get List Values From Multi-Select List + ${values}= Get List Items interests label=${False} ${expected}= Create List males females others Should Be Equal ${values} ${expected} From ec5745789648cb277c0af0d11df8ba6425c7e7d7 Mon Sep 17 00:00:00 2001 From: Jacky Qi Date: Tue, 3 Jan 2017 11:47:50 +0800 Subject: [PATCH 5/9] change test place and change ${False} to False place the test before the Get Selected List Value --- test/acceptance/keywords/lists.robot | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index dff0bf901..f2b5d0067 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -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 label=False + ${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 label=False + ${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 @@ -148,18 +160,6 @@ List Should Have No Selections ... List 'interests' should have had no selection (selection was [ Males | Females | Others ]) ... List Should Have No Selections interests -Get List Values From Single-Select List - [Documentation] Get List Values From Single-Select List - ${values}= Get List Items preferred_channel label=${False} - ${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 label=${False} - ${expected}= Create List males females others - Should Be Equal ${values} ${expected} - *** Keywords *** Unselect And Verify Selection [Documentation] Unselect And Verify Selection From a0421eb15b6bbb4319458a288542eed6b228cc8f Mon Sep 17 00:00:00 2001 From: Jacky Qi Date: Tue, 3 Jan 2017 11:48:23 +0800 Subject: [PATCH 6/9] change Sample to Example and change ${False} to False --- src/Selenium2Library/keywords/_selectelement.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 48dcbaab3..ce9d8ff39 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -15,10 +15,10 @@ def get_list_items(self, locator, label=True): select lists are `id` and `name`. See `introduction` for details about locating elements. - Sample: + Example: | ${labels1} = | Get List Items | xpath=//h1 | - | ${labels2} = | Get List Items | xpath=//h1 | label=${True} | - | ${values} = | Get List Items | xpath=//h1 | label=${False} | + | ${labels2} = | Get List Items | xpath=//h1 | label=True | + | ${values} = | Get List Items | xpath=//h1 | label=False | | Should Be Equal | ${labels1} | ${labels2} | """ select, options = self._get_select_list_options(locator) From 74049a4a214a5d8b6b0d7a153e9aa23a3789b58e Mon Sep 17 00:00:00 2001 From: qitao Date: Wed, 11 Jan 2017 21:13:19 +0800 Subject: [PATCH 7/9] modify argument label=True to value=False modify argument label=True to value=False and the test cases. --- .../keywords/_selectelement.py | 14 +++++------ test/acceptance/keywords/lists.robot | 24 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 48dcbaab3..187bde9b9 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -8,8 +8,8 @@ class _SelectElementKeywords(KeywordGroup): # Public - def get_list_items(self, locator, label=True): - """Returns the labels or values in the select list identified by `locator`. + def get_list_items(self, locator, value=False): + """Returns the values or labels 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 @@ -17,15 +17,15 @@ def get_list_items(self, locator, label=True): Sample: | ${labels1} = | Get List Items | xpath=//h1 | - | ${labels2} = | Get List Items | xpath=//h1 | label=${True} | - | ${values} = | Get List Items | xpath=//h1 | label=${False} | + | ${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) - if label: - return self._get_labels_for_options(options) - else: + 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`. diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index dff0bf901..3f0ecc58f 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -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 @@ -148,18 +160,6 @@ List Should Have No Selections ... List 'interests' should have had no selection (selection was [ Males | Females | Others ]) ... List Should Have No Selections interests -Get List Values From Single-Select List - [Documentation] Get List Values From Single-Select List - ${values}= Get List Items preferred_channel label=${False} - ${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 label=${False} - ${expected}= Create List males females others - Should Be Equal ${values} ${expected} - *** Keywords *** Unselect And Verify Selection [Documentation] Unselect And Verify Selection From a0ca5e9257269a237511e991eb0c5f17b4b8f681 Mon Sep 17 00:00:00 2001 From: qitao Date: Wed, 11 Jan 2017 21:22:44 +0800 Subject: [PATCH 8/9] Revert "modify argument label=True to value=False" This reverts commit 74049a4a214a5d8b6b0d7a153e9aa23a3789b58e. --- .../keywords/_selectelement.py | 14 +++++------ test/acceptance/keywords/lists.robot | 24 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 187bde9b9..48dcbaab3 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -8,8 +8,8 @@ class _SelectElementKeywords(KeywordGroup): # Public - def get_list_items(self, locator, value=False): - """Returns the values or labels in the select list identified by `locator`. + def get_list_items(self, locator, label=True): + """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 @@ -17,15 +17,15 @@ def get_list_items(self, locator, value=False): Sample: | ${labels1} = | Get List Items | xpath=//h1 | - | ${labels2} = | Get List Items | xpath=//h1 | value=${False} | - | ${values} = | Get List Items | xpath=//h1 | value=${True} | + | ${labels2} = | Get List Items | xpath=//h1 | label=${True} | + | ${values} = | Get List Items | xpath=//h1 | label=${False} | | Should Be Equal | ${labels1} | ${labels2} | """ select, options = self._get_select_list_options(locator) - if value: - return self._get_values_for_options(options) - else: + if label: return self._get_labels_for_options(options) + else: + return self._get_values_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`. diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index 3f0ecc58f..dff0bf901 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -17,18 +17,6 @@ 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 @@ -160,6 +148,18 @@ List Should Have No Selections ... List 'interests' should have had no selection (selection was [ Males | Females | Others ]) ... List Should Have No Selections interests +Get List Values From Single-Select List + [Documentation] Get List Values From Single-Select List + ${values}= Get List Items preferred_channel label=${False} + ${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 label=${False} + ${expected}= Create List males females others + Should Be Equal ${values} ${expected} + *** Keywords *** Unselect And Verify Selection [Documentation] Unselect And Verify Selection From 215030a2bc373083a6855e0f80ed7a0884b0ba7a Mon Sep 17 00:00:00 2001 From: qitao Date: Wed, 11 Jan 2017 21:27:36 +0800 Subject: [PATCH 9/9] modify argument label=True to value=False modify argument label=True to value=False and modify the cases. --- src/Selenium2Library/keywords/_selectelement.py | 12 ++++++------ test/acceptance/keywords/lists.robot | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index ce9d8ff39..1f0b6cd37 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -8,7 +8,7 @@ class _SelectElementKeywords(KeywordGroup): # Public - def get_list_items(self, locator, label=True): + 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 @@ -17,15 +17,15 @@ def get_list_items(self, locator, label=True): Example: | ${labels1} = | Get List Items | xpath=//h1 | - | ${labels2} = | Get List Items | xpath=//h1 | label=True | - | ${values} = | Get List Items | xpath=//h1 | label=False | + | ${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) - if label: - return self._get_labels_for_options(options) - else: + 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`. diff --git a/test/acceptance/keywords/lists.robot b/test/acceptance/keywords/lists.robot index f2b5d0067..694fe33f1 100644 --- a/test/acceptance/keywords/lists.robot +++ b/test/acceptance/keywords/lists.robot @@ -19,13 +19,13 @@ Get List Items From Multi-Select List Get List Values From Single-Select List [Documentation] Get List Values From Single-Select List - ${values}= Get List Items preferred_channel label=False + ${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 label=False + ${values}= Get List Items interests value=True ${expected}= Create List males females others Should Be Equal ${values} ${expected}