From fc87567a56fb9e18af23743958bd85956a1a9c31 Mon Sep 17 00:00:00 2001 From: Simon Baars Date: Thu, 19 Mar 2020 17:07:25 +0100 Subject: [PATCH 1/2] #206 Remove config source when quitting driver --- selene/core/entity.py | 1 + 1 file changed, 1 insertion(+) diff --git a/selene/core/entity.py b/selene/core/entity.py index 355657ed..4a9c8c4e 100644 --- a/selene/core/entity.py +++ b/selene/core/entity.py @@ -981,6 +981,7 @@ def close_current_tab(self) -> Browser: def quit(self) -> None: self.driver.quit() + self.config._source.put(None) def clear_local_storage(self) -> Browser: self.driver.execute_script('window.localStorage.clear();') # todo: should we catch and ignore errors? From 08e04bc86af74e5e21c0f672fb57e1916dd45542 Mon Sep 17 00:00:00 2001 From: Simon Baars Date: Fri, 20 Mar 2020 10:46:13 +0100 Subject: [PATCH 2/2] #206 Improved design of browser quit() --- selene/core/entity.py | 1 - selene/support/shared/browser.py | 4 ++++ selene/support/shared/config.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/selene/core/entity.py b/selene/core/entity.py index 4a9c8c4e..355657ed 100644 --- a/selene/core/entity.py +++ b/selene/core/entity.py @@ -981,7 +981,6 @@ def close_current_tab(self) -> Browser: def quit(self) -> None: self.driver.quit() - self.config._source.put(None) def clear_local_storage(self) -> Browser: self.driver.execute_script('window.localStorage.clear();') # todo: should we catch and ignore errors? diff --git a/selene/support/shared/browser.py b/selene/support/shared/browser.py index a8821adb..8a75c122 100644 --- a/selene/support/shared/browser.py +++ b/selene/support/shared/browser.py @@ -121,6 +121,10 @@ 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: + super().quit() + self.config.reset_source() + 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..ba156ed4 100644 --- a/selene/support/shared/config.py +++ b/selene/support/shared/config.py @@ -219,6 +219,9 @@ def wait(self, entity): hook = self._inject_screenshot_and_page_source_pre_hooks(self.hook_wait_failure) return Wait(entity, at_most=self.timeout, or_fail_with=hook) + def reset_source(self): + self._source = Source() + # --- Config.* added setters --- # @Config.timeout.setter