Skip to content

Commit

Permalink
Merge branch 'issue-206' of https://github.com/SimonBaars/selene into…
Browse files Browse the repository at this point in the history
… SimonBaars-issue-206
  • Loading branch information
yashaka committed Mar 20, 2020
2 parents 283c849 + 08e04bc commit b0ab76d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions selene/support/shared/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 9 additions & 1 deletion selene/support/shared/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b0ab76d

Please sign in to comment.