Skip to content

Commit 46a7cb1

Browse files
Merge pull request #10 from HelioGuilherme66/fix_unselect
Fixes `Unselect From List` due to Selenium changes.
2 parents 1a2a14f + bf5c56f commit 46a7cb1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Selenium2Library/keywords/_selectelement.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,17 @@ def unselect_from_list(self, locator, *items):
274274

275275
select, options = self._get_select_list_options(select)
276276
for item in items:
277-
select.deselect_by_value(item)
278-
select.deselect_by_visible_text(item)
277+
try:
278+
select.deselect_by_value(item)
279+
# Code for selenium <= 2.52.0
280+
select.deselect_by_visible_text(item)
281+
except: # Code for selenium > 2.52.0
282+
try:
283+
select.deselect_by_visible_text(item)
284+
except:
285+
self._warn("Tried to unselect missing selection item, \
286+
'%s' from locator '%s'." % (item, locator))
287+
continue
279288

280289
def unselect_from_list_by_index(self, locator, *indexes):
281290
"""Unselects `*indexes` from list identified by `locator`

0 commit comments

Comments
 (0)