Files
pytest-screenshots/conftest.py
Ivan Vazhenin cd1c20d054 Fix tests
2023-07-04 19:13:49 +03:00

51 lines
1.7 KiB
Python

import pytest
import logging
import allure
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.chrome.service import Service
class Config:
BASE_URL = "baseurl"
STAGING = "staging"
@pytest.fixture()
def driver():
options = ChromeOptions()
options.add_argument("--headless")
webdriver = Chrome(service=Service(executable_path='/home/ashatora/yandexdriver'), options=options)
webdriver.implicitly_wait(2)
yield webdriver
allure.attach(webdriver.current_url, "last url", allure.attachment_type.URI_LIST)
webdriver.quit()
def pytest_addoption(parser):
"""Command line parser."""
parser.addoption(f'--{Config.BASE_URL}',
default='https://s57test.ivazh.ru/',
dest=Config.BASE_URL,
action='store',
metavar='str',
help='Environment for run tests.')
parser.addoption(f'--{Config.STAGING}',
default='s57test.ivazh.ru',
dest=Config.STAGING,
action='store',
metavar='str',
help='Environment for compare with testing.')
parser.addoption('--log_level',
default='INFO',
dest='log_level',
action='store',
metavar='str',
help='Logging level.')
def pytest_configure(config):
"""Configure test run."""
logging.basicConfig(level=config.getoption('log_level'),
format='%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)',
datefmt='%Y-%m-%d %H:%M:%S')