Skip to content
conftest.py 636 B
Newer Older
admin's avatar
admin committed
import pytest
admin's avatar
admin committed
from datetime import datetime
import allure
admin's avatar
admin committed
import os
admin's avatar
admin committed
from selenium import webdriver

admin's avatar
admin committed
host = os.environ.get('MAIN_HOST')
admin's avatar
admin committed
port = os.environ.get('MAIN_PORT')
admin's avatar
admin committed

admin's avatar
admin committed
@pytest.fixture(scope='function')
def driver():
    options = webdriver.ChromeOptions()
admin's avatar
admin committed
    options.add_argument('--headless')
    driver = webdriver.Remote(
admin's avatar
admin committed
    command_executor=f'http://{host}:{port}/wd/hub', options=options)
admin's avatar
admin committed
    driver.maximize_window()
    yield driver
admin's avatar
admin committed
    attach = driver.get_screenshot_as_png()
    allure.attach(attach, name=f"Screenshot {datetime.today()}", attachment_type=allure.attachment_type.PNG)
admin's avatar
admin committed
    driver.quit()