-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconftest.py
More file actions
28 lines (24 loc) · 923 Bytes
/
conftest.py
File metadata and controls
28 lines (24 loc) · 923 Bytes
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
import pytest
import sys
from selenium import webdriver
# tell python where our modules are...
sys.path.append('pages')
sys.dont_write_bytecode = True
# add cli options...
def pytest_addoption(parser):
parser.addoption('--url', action='store', default='https://qualityshepherd.com', help='specify the base URL to test against')
parser.addoption('--driver', action='store', default='chrome', help='chrome or firefox')
# driver fixture passed to all tests
@pytest.fixture(scope='session')
def driver(request):
driver = request.config.getoption('--driver')
if driver == 'firefox' or driver == 'ff':
driver = webdriver.Firefox()
elif driver == 'chrome':
driver = webdriver.Chrome()
else:
raise ValueError('invalid driver name: ' + driver)
driver.set_window_size(1200, 800)
driver.base_url = request.config.getoption('--url') or 'https://qualityshepherd.com/'
yield driver
driver.quit()