<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_for_alert(self, timeout=None):
 """ Shortcut for waiting for alert. If it not ends with exception, it returns that alert. Detault timeout is `~.default_wait_timeout`. """

        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