def elem_is_visible_with_wait(context, elem, wait_time=MAX_WAIT_TIME):
 def _visiblity_of():
  context.browser.execute_script(('$(window).scrollLeft(%s);$(window).scrollTop(%s);' % (elem.location['x'], elem.location['y'])))
  return elem.is_displayed()
 try:
  WebDriverWait(context.browser, wait_time).until((lambda browser: _visiblity_of()))
  return True
 except (TimeoutException, StaleElementReferenceException):
  return False

def elem_is_visible_with_wait ( context , elem , wait_time = MAX_WAIT_TIME ) : def _visiblity_of ( ) : context . browser . execute_script ( ( '$(window).scrollLeft(%s);$(window).scrollTop(%s);' % ( elem . location [ 'x' ] , elem . location [ 'y' ] ) ) ) return elem . is_displayed ( ) try : WebDriverWait ( context . browser , wait_time ) . until ( ( lambda browser : _visiblity_of ( ) ) ) return True except ( TimeoutException , StaleElementReferenceException ) : return False
waits for the element to become visible .