def get_selected_option_text(select_browser_query):
 def get_option(query):
  ' Get the first select element that matches the query and return its value. '
  try:
   select = Select(query.first.results[0])
   return (True, select.first_selected_option.text)
  except StaleElementReferenceException:
   return (False, None)
 text = Promise((lambda : get_option(select_browser_query)), 'Retrieved selected option text').fulfill()
 return text

def get_selected_option_text ( select_browser_query ) : def get_option ( query ) : try : select = Select ( query . first . results [ 0 ] ) return ( True , select . first_selected_option . text ) except StaleElementReferenceException : return ( False , None ) text = Promise ( ( lambda : get_option ( select_browser_query ) ) , 'Retrieved selected option text' ) . fulfill ( ) return text
returns the text value for the first selected option within a select .