-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
81 lines (68 loc) · 2.21 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
__author__ = "sarvesh.singh"
from base.common import get_resource_config
import os
from collections import namedtuple
import pytest
from base.web_drivers import WebDriver
from pages.home_page import HomePage
from pages.search_results import SearchResults
def pytest_configure(config):
"""
Configuration changes for PyTest
:param config:
:return:
"""
os.environ["ROOT_PATH"] = config.rootdir.strpath
config.option.cacheclear = True
config.option.capture = "sys" # no: for no output at all
config.option.clean_alluredir = True
config.option.color = "yes"
config.option.disable_warnings = True
config.option.instafail = True
config.option.failedfirst = True
config.option.json_report_indent = 2
config.option.json_report_omit = ["warnings"]
config.option.json_report = True
config.option.maxfail = 1
config.option.pythonwarnings = ["ignore:Unverified HTTPS request"]
config.option.tbstyle = "short"
config.option.self_contained_html = True
config.option.verbose = 1
if config.getoption("allure_report_dir") is None:
config.option.allure_report_dir = f"allure-results"
if config.getoption("json_report_file") == ".report.json":
config.option.json_report_file = f"report.json"
if config.getoption("htmlpath") is None:
config.option.htmlpath = f"report.html"
if config.getoption("xmlpath") is None:
config.option.xmlpath = f"report.xml"
@pytest.fixture(autouse=True, scope="session")
def resources():
"""
resources Fixture with all Url
:return:
"""
return get_resource_config()
@pytest.fixture(scope='session')
def web_driver():
"""
Fixture to initialise the web driver
:return:
"""
driver = WebDriver(browser='chrome')
yield driver
try:
driver.driver.close()
except (Exception, ValueError):
pass
@pytest.fixture(scope='session')
def pages(web_driver):
"""
Fixture to initialise the Page Class
:param web_driver
:return:
"""
named_tuple = namedtuple("pages", ["pages"])
setattr(named_tuple, 'home', HomePage(web_driver=web_driver))
setattr(named_tuple, 'search', SearchResults(web_driver=web_driver))
return named_tuple