Skip to content

Commit

Permalink
Merge branch 'feature/env-config-variables' of https://github.com/Ser…
Browse files Browse the repository at this point in the history
…geyPirogov/selene into SergeyPirogov-feature/env-config-variables
  • Loading branch information
yashaka committed Feb 22, 2017
2 parents 74f0096 + 99ff7fb commit 204b655
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
35 changes: 24 additions & 11 deletions selene/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,37 @@
import time

from selene.browsers import Browser
from selene.helpers import env

timeout = 4
poll_during_waits = 0.1
app_host = ''
SELENE_TIMEOUT = "selene_timeout"
SELENE_POOLING_INTERVAL = "selene_polling_interval"
SELENE_BASE_URL = 'selene_base_url'
SELENE_BROWSER = 'selene_browser'
SELENE_START_MAXIMIZED = "selene_start_maximized"
SELENE_HOLD_BROWSER_OPEN = "selene_hold_browser_open"
SELENE_CACHE_ELEMENTS = "selene_cache_elements"
SELENE_SCREENSHOT_FOLDER = "selene_screenshot_folder"

timeout = env(SELENE_TIMEOUT) or 4
poll_during_waits = env(SELENE_POOLING_INTERVAL) or 0.1
app_host = env(SELENE_BASE_URL) or ''

# todo: make cashing work (currently will not work...)
cash_elements = False
cash_elements = env(SELENE_CACHE_ELEMENTS) == "True" or False
"""To cash all elements after first successful find
config.cash_elements = True"""

browser_name = Browser.FIREFOX
maximize_window = True
hold_browser_open = False
browser_name = env(SELENE_BROWSER) or Browser.FIREFOX

maximize_window = False if env(SELENE_START_MAXIMIZED) == "False" else True

hold_browser_open = env(SELENE_HOLD_BROWSER_OPEN) == "True" or False

counter = itertools.count(start=int(round(time.time() * 1000)))

screenshot_folder = os.path.join(os.path.expanduser("~"),
".selene",
"screenshots",
str(next(counter)))
screenshot_folder = env(SELENE_SCREENSHOT_FOLDER) or os.path.join(os.path.expanduser("~"),
".selene",
"screenshots",
str(next(counter)))

desired_capabilities = None
7 changes: 7 additions & 0 deletions selene/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ def css_or_by_to_by(css_selector_or_by):
if isinstance(css_selector_or_by, str):
return (By.CSS_SELECTOR, css_selector_or_by)
raise TypeError('css_selector_or_by should be str with CSS selector or Tuple[by:str, value:str]')


def env(key):
try:
return os.environ[key]
except KeyError:
return None

0 comments on commit 204b655

Please sign in to comment.