diff --git a/src/Selenium2Library/keywords/_selectelement.py b/src/Selenium2Library/keywords/_selectelement.py index 496289bed..a89553d84 100644 --- a/src/Selenium2Library/keywords/_selectelement.py +++ b/src/Selenium2Library/keywords/_selectelement.py @@ -1,5 +1,7 @@ from selenium.webdriver.support.ui import Select from keywordgroup import KeywordGroup +from selenium.common.exceptions import NoSuchElementException + class _SelectElementKeywords(KeywordGroup): @@ -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`