-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
38 lines (30 loc) · 1.08 KB
/
conftest.py
File metadata and controls
38 lines (30 loc) · 1.08 KB
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
29
30
31
32
33
34
35
36
37
38
import pytest
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
import allure
from allure_commons.types import AttachmentType
@pytest.fixture(scope="function")
def driver():
# Настройка Firefox
firefox_options = Options()
firefox_options.add_argument("--width=1920")
firefox_options.add_argument("--height=1080")
# Инициализация драйвера
driver = webdriver.Firefox(options=firefox_options)
driver.implicitly_wait(10)
yield driver
# Закрытие драйвера после теста
driver.quit()
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
if rep.when == "call" and rep.failed:
driver = item.funcargs.get("driver")
if driver:
allure.attach(
driver.get_screenshot_as_png(),
name="screenshot",
attachment_type=AttachmentType.PNG
)