def select_option_by_value(browser_query, value):
 select = Select(browser_query.first.results[0])
 select.select_by_value(value)
 def options_selected():
  '\n        Returns True if all options in select element where value attribute\n        matches `value`. if any option is not selected then returns False\n        and select it. if value is not an option choice then it returns False.\n        '
  all_options_selected = True
  has_option = False
  for opt in select.options:
   if (opt.get_attribute('value') == value):
    has_option = True
    if (not opt.is_selected()):
     all_options_selected = False
     opt.click()
  if (all_options_selected and (not has_option)):
   all_options_selected = False
  return all_options_selected
 EmptyPromise(options_selected, 'Option is selected').fulfill()

def select_option_by_value ( browser_query , value ) : select = Select ( browser_query . first . results [ 0 ] ) select . select_by_value ( value ) def options_selected ( ) : all_options_selected = True has_option = False for opt in select . options : if ( opt . get_attribute ( 'value' ) == value ) : has_option = True if ( not opt . is_selected ( ) ) : all_options_selected = False opt . click ( ) if ( all_options_selected and ( not has_option ) ) : all_options_selected = False return all_options_selected EmptyPromise ( options_selected , 'Option is selected' ) . fulfill ( )
selects a html select element by matching value attribute .