import pytest from datetime import datetime import allure import os from selenium import webdriver host = os.environ.get('MAIN_HOST') port = os.environ.get('MAIN_PORT') @pytest.fixture(scope='function') def driver(): options = webdriver.ChromeOptions() options.add_argument('--headless') driver = webdriver.Remote( command_executor=f'http://{host}:{port}/wd/hub', options=options) driver.maximize_window() yield driver attach = driver.get_screenshot_as_png() allure.attach(attach, name=f"Screenshot {datetime.today()}", attachment_type=allure.attachment_type.PNG) driver.quit()