diff --git a/airgun/session.py b/airgun/session.py index e9aef0949..ce2893ee5 100644 --- a/airgun/session.py +++ b/airgun/session.py @@ -232,7 +232,7 @@ def __exit__(self, exc_type, exc_value, traceback): not risen not to shadow real session result. """ if self.browser is None: - # browser was never started, don't do anything + # browser hasn't been started or was already closed, don't do anything return LOGGER.info('Stopping UI session %r for user %r', self.name, self._user) passed = True if exc_type is None else False @@ -242,7 +242,7 @@ def __exit__(self, exc_type, exc_value, traceback): except Exception as err: # - TODO: fix bare except LOGGER.exception(err) finally: - self._factory.finalize(passed) + self.browser = self._factory.finalize(passed) def _open(self, entity): """Initializes requested entity. If this is first time session