Files
pytest-screenshots/conftest.py
2022-09-28 12:55:33 +03:00

50 lines
1.6 KiB
Python

import pytest
import logging
import allure
from selenium.webdriver import Chrome, ChromeOptions
class Config:
BASE_URL = "baseurl"
STAGING = "staging"
@pytest.fixture()
def driver():
options = ChromeOptions()
options.add_argument("--headless")
webdriver = Chrome('/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://s57.ivazh.ru/styles/r14/#12.13/71.2832/72.13405',
dest=Config.BASE_URL,
action='store',
metavar='str',
help='Environment for run tests.')
parser.addoption(f'--{Config.STAGING}',
default='s57.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')