diff --git a/selene/support/shared/browser.py b/selene/support/shared/browser.py index a8821adb..2bf2c99b 100644 --- a/selene/support/shared/browser.py +++ b/selene/support/shared/browser.py @@ -121,6 +121,9 @@ def latest_page_source(self): warnings.warn('browser.latest_page_source prop is deprecated, use browser.last_page_source', DeprecationWarning) return self.config.last_page_source + def quit(self) -> None: + self.config.quit_driver() + def quit_driver(self): warnings.warn('deprecated; use browser.quit() instead', DeprecationWarning) self.quit() diff --git a/selene/support/shared/config.py b/selene/support/shared/config.py index 9eaddfdb..0fc64f1c 100644 --- a/selene/support/shared/config.py +++ b/selene/support/shared/config.py @@ -52,6 +52,9 @@ def __init__(self, value: T = None): def put(self, value: T): self._value = value + def clear(self): + self._value = None + @property def value(self) -> T: return self._value @@ -152,13 +155,18 @@ def driver(self) -> WebDriver: return new + def quit_driver(self): + self._source.value.quit() + self._source.clear() + @driver.setter def driver(self, value: WebDriver): stored = self._source.value is_another_driver = on_error_return_false(lambda: value.session_id != stored.session_id) if is_another_driver: - stored.quit() # todo: can quit raise exception? handle then... + # todo: do we really need to quit old driver? + self.quit_driver() # todo: can quit raise exception? handle then... self._source.put(value)