def elem_is_invisible_with_wait(context, elem, wait_time=MAX_WAIT_TIME):
 try:
  if (not elem.is_displayed()):
   return True
 except StaleElementReferenceException:
  return True
 def displayed_condition(driver):
  try:
   return (not elem.is_displayed())
  except StaleElementReferenceException:
   return True
 try:
  WebDriverWait(context.browser, wait_time).until(displayed_condition)
  return True
 except TimeoutException:
  return False

def elem_is_invisible_with_wait ( context , elem , wait_time = MAX_WAIT_TIME ) : try : if ( not elem . is_displayed ( ) ) : return True except StaleElementReferenceException : return True def displayed_condition ( driver ) : try : return ( not elem . is_displayed ( ) ) except StaleElementReferenceException : return True try : WebDriverWait ( context . browser , wait_time ) . until ( displayed_condition ) return True except TimeoutException : return False
waits for the element to become invisible context: a behave context elem: a webdriver element wait_time: sets the max wait time .