-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
36 lines (27 loc) · 1.07 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
import inspect
import pytest
def pytest_addoption(parser):
parser.addoption("--browser", action="store", default="chrome", help="Type in browser name e.g. chrome OR firefox")
@pytest.fixture(autouse=True, scope="class")
def test_setup(request):
global driver
from selenium import webdriver
browser = request.config.getoption("--browser")
if browser == 'chrome':
driver = webdriver.Chrome(executable_path="./Drivers/chromedriver.exe")
elif browser == 'firefox':
driver = webdriver.Firefox(executable_path="./Drivers/geckodriver.exe")
# driver.implicitly_wait(3)
driver.get("https://demo.nopcommerce.com/")
driver.maximize_window()
request.cls.driver = driver
yield
driver.close()
driver.quit()
print("Test completed")
def whoami():
return inspect.stack()[1][3]
def pytest_report_header(config):
if config.getoption("verbose") > 0:
return ["###############################################################"
" RUNNING TESTS IN VERBOSE MODE#################################################"]