-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
43 lines (35 loc) · 1.15 KB
/
conftest.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
import pytest
from application import Application
def pytest_addoption(parser):
parser.addoption(
"--addconfig", action="append", default=[],
help="Add a platform and its supported browsers. " +
"Format: platform:browser1,browser2")
def pytest_generate_tests(metafunc):
platform_browsers = []
for config in metafunc.config.getoption('addconfig'):
platform = config.split(':')[0]
browsers = config.split(':')[1].split(',')
platform_browsers += map(lambda x: (x, platform), browsers)
metafunc.parametrize(
'browser_name, platform',
platform_browsers,
scope='session'
)
@pytest.fixture(scope='session')
def app(browser_name, platform):
"""
Returns an application that initializes a webdriver instance
:param browser_name: Name of browser
:param platform: Name of platform
:return: Application
"""
return Application(browser_name, platform)
@pytest.fixture(autouse=True, scope='session')
def config(app):
"""
Cleanup code that quits the browser after session end
:param app: Application instance
"""
yield
app.driver.quit()