Skip to content

Commit

Permalink
env config set added
Browse files Browse the repository at this point in the history
  • Loading branch information
sepi committed Feb 17, 2017
1 parent acdee40 commit 99ff7fb
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 99ff7fb

Please sign in to comment.