code: def wait_for_alert(self, timeout=None):
          
          if not timeout:
              timeout = self.default_wait_timeout
  
          alert = Alert(self)
  
          # There is no better way how to check alert appearance
          def alert_shown(driver):
              try:
                  alert.text
                  return True
              except selenium_exc.NoAlertPresentException:
                  return False
  
          self.wait(timeout).until(alert_shown)
  
          return alert
docs: Shortcut for waiting for alert. If it not ends with exception, it
          returns that alert. Detault timeout is `~.default_wait_timeout`.