This repository has been archived by the owner on May 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
environment.py
65 lines (54 loc) · 1.81 KB
/
environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from selenium import webdriver
from selenium.webdriver.remote.remote_connection import RemoteConnection
from automation_helpers import AutomationHelpers
from os import environ
from erppeek import Client
def get_browser():
"""
Get the browser to use
:return: Selenium driver
"""
if environ.get('GO_PIPELINE_LABEL'):
options = webdriver.ChromeOptions()
options.add_argument('--headless')
desired_caps = options.to_capabilities()
selenium_host = environ.get('GATEWAY', 'localhost')
selenium_endpoint = "http://{}:4444/wd/hub".format(selenium_host)
print('using URL: {}'.format(selenium_endpoint))
executor = RemoteConnection(selenium_endpoint, resolve_ip=False)
browser = webdriver.Remote(
command_executor=executor,
desired_capabilities=desired_caps,
)
return browser
else:
return webdriver.Chrome()
def before_all(context):
"""
Before all features and scenarios are run set up environment
:param context: Behave context
"""
context.driver = get_browser()
context.helpers = AutomationHelpers('config.yml')
context.client = Client(
context.helpers.config.get('server'),
context.helpers.config.get('database'),
user='admin',
password='admin',
)
_create_patient_lookup(context)
def after_all(context):
"""
After all features and scenarios are run clean up the environment
:param context: Behave context
"""
context.driver.quit()
def _create_patient_lookup(context):
"""
Patients will be added to this dictionary when they are created in setup
steps using the patient's given name as a key.
This allows quick lookup in subsequent steps.
:param context:
:return:
"""
context.patients = {}