def select_option_by_text(select_browser_query, option_text):
 def select_option(query, value):
  ' Get the first select element that matches the query and select the desired value. '
  try:
   select = Select(query.first.results[0])
   select.select_by_visible_text(value)
   return True
  except StaleElementReferenceException:
   return False
 msg = 'Selected option {}'.format(option_text)
 EmptyPromise((lambda : select_option(select_browser_query, option_text)), msg).fulfill()

def select_option_by_text ( select_browser_query , option_text ) : def select_option ( query , value ) : try : select = Select ( query . first . results [ 0 ] ) select . select_by_visible_text ( value ) return True except StaleElementReferenceException : return False msg = 'Selected option {}' . format ( option_text ) EmptyPromise ( ( lambda : select_option ( select_browser_query , option_text ) ) , msg ) . fulfill ( )
chooses an option within a select by text .