Skip to content

Commit

Permalink
#172: if driver was set like shared.config.driver = my_custom_driver …
Browse files Browse the repository at this point in the history
…then it's not mandatory to call shared.browser.open first; bumped 2.0.0a26
  • Loading branch information
yashaka committed May 19, 2020
1 parent 5078c2f commit 3e727c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
- consider cofig.headless = False like in selenide
- `this.browser = new Browser(config.browser(), config.headless());`

## 2.0.0a27 (to be released on ?.05.2020)
## 2.0.0a28 (to be released on ?.05.2020)
- todo: add something like element.click_with_offset
- todo: add something like browser.perform(switch_to_tab('my tab title'))
- maybe make browser.switch ... to work with retry logic
Expand All @@ -59,15 +59,19 @@
- The variable __all__ is a list of public objects of that module, as interpreted by import *. ... In other words, __all__ is a list of strings defining what symbols in a module will be exported when from <module> import * is used on the module


## 2.0.0a26 (to be released on ?.06.2020)
## 2.0.0a27 (to be released on ?.06.2020)
- todo: improve for other all.* methods (in addition to improved errors from browser.all.element_by)
- todo: why in the past we had when outer_html this: '<button class="destroy" type="submit" displayed:false></button>'
- but now we have this: '<button class="destroy" type="submit"></button>'?
- can we improve it?
- add browser.all('.item').last?
- make browser.switch_to.frame to accept element

## 2.0.0a26 (to be released on 19.05.2020)
- if driver was set like `shared.config.driver = my_custom_driver`
- then it's not mandatory to call `shared.browser.open` first

## 2.0.0a25 (to be released on ?.05.2020)
## 2.0.0a25 (released on 18.05.2020)
- fixing [#172](https://github.com/yashaka/selene/issues/172)
- added `shared.config.set_driver: Callable[[], WebDriver]`
as alternative to `shared.config.driver: WebDriver`
Expand Down
2 changes: 1 addition & 1 deletion selene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
# """
# todo: add here some type imports like Element, Collection, etc.

__version__ = '2.0.0a25'
__version__ = '2.0.0a26'

# --- DEPRECATED, and will be removed soon --- #

Expand Down
13 changes: 10 additions & 3 deletions selene/support/shared/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def instance(self) -> WebDriver:

return self._stored

def _create(self) -> WebDriver:
def create(self) -> WebDriver:
self._stored = self._set_driver()

if not self._hold_browser_open:
Expand All @@ -118,7 +118,7 @@ def get_or_create(self) -> WebDriver:
if self.has_webdriver_started():
self.quit()

return self._create()
return self.create()

def quit(self):
if self.has_webdriver_started():
Expand Down Expand Up @@ -162,6 +162,7 @@ def __init__(self,

self._browser_name = browser_name
self._hold_browser_open = hold_browser_open
self._source = source or _LazyDriver(self)

def set_chrome_or_firefox_from_webdriver_manager():
# todo: consider simplifying implementation to simple if-else
Expand Down Expand Up @@ -191,10 +192,15 @@ def set_firefox():
}.get(self.browser_name)()

if driver and not set_driver:
'''
each time we are setting not None driver,
we have to not forget to call self._source.create()
todo: how can we improve cohesion here? and reduce risks?
'''
self._set_driver = lambda: driver
self._source.create()
else:
self._set_driver = set_driver or set_chrome_or_firefox_from_webdriver_manager
self._source = source or _LazyDriver(self)

self._save_screenshot_on_failure = save_screenshot_on_failure
self._save_page_source_on_failure = save_page_source_on_failure
Expand Down Expand Up @@ -241,6 +247,7 @@ def quit_driver(self):
@driver.setter
def driver(self, value: WebDriver):
self.set_driver = lambda: value
self._source.create()

@property
def set_driver(self):
Expand Down

0 comments on commit 3e727c6

Please sign in to comment.