Skip to content

Commit bf5c56f

Browse files
Fixes Unselect From List due to Selenium changes.
Since Selenium version 2.53.0 deselect_by_value/label returns boolean, and Exception if element is not found. This fix keeps compatibility with versions <=2.52.0.
1 parent 6ef0ddb commit bf5c56f

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
@@ -271,8 +271,17 @@ def unselect_from_list(self, locator, *items):
271271

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

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

0 commit comments

Comments
 (0)