def rate_id(context, id_, val=3):
 def rate_element(driver):
  try:
   inner_wrapper = find_id_with_wait(context, id_, wait_time=2)
   els = inner_wrapper.find_elements_by_class_name(STAR_RATING_OPTION_CLASS)
   rating_el = [el for el in filter((lambda x: (int(x.get_attribute('data-val')) == val)), els)][0]
   rating_el.click()
   return True
  except (NoSuchElementException, StaleElementReferenceException, TimeoutException, IndexError):
   return False
 try:
  WebDriverWait(context.browser, 30).until(rate_element)
 except TimeoutException:
  raise Exception("Unable to enter rating for container with id '{id:s}'".format(id=id_))

def rate_id ( context , id_ , val = 3 ) : def rate_element ( driver ) : try : inner_wrapper = find_id_with_wait ( context , id_ , wait_time = 2 ) els = inner_wrapper . find_elements_by_class_name ( STAR_RATING_OPTION_CLASS ) rating_el = [ el for el in filter ( ( lambda x : ( int ( x . get_attribute ( 'data-val' ) ) == val ) ) , els ) ] [ 0 ] rating_el . click ( ) return True except ( NoSuchElementException , StaleElementReferenceException , TimeoutException , IndexError ) : return False try : WebDriverWait ( context . browser , 30 ) . until ( rate_element ) except TimeoutException : raise Exception ( "Unable to enter rating for container with id '{id:s}'" . format ( id = id_ ) )
enter a star rating given the id of the container .