Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Selenium2Library/keywords/_selectelement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from selenium.webdriver.support.ui import Select
from keywordgroup import KeywordGroup
from selenium.common.exceptions import NoSuchElementException


class _SelectElementKeywords(KeywordGroup):

Expand Down Expand Up @@ -271,17 +273,16 @@ def unselect_from_list(self, locator, *items):

select, options = self._get_select_list_options(select)
for item in items:
# Only Selenium 2.52 and newer raise exceptions when there is no match.
# For backwards compatibility reasons we want to ignore them.
try:
select.deselect_by_value(item)
# Code for selenium <= 2.52.0
except NoSuchElementException:
pass
try:
select.deselect_by_visible_text(item)
except: # Code for selenium > 2.52.0
try:
select.deselect_by_visible_text(item)
except:
self._warn("Tried to unselect missing selection item, \
'%s' from locator '%s'." % (item, locator))
continue
except NoSuchElementException:
pass

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