-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconftest.py
More file actions
25 lines (18 loc) · 765 Bytes
/
conftest.py
File metadata and controls
25 lines (18 loc) · 765 Bytes
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
import pytest
from pathlib import Path
def pytest_runtest_makereport(item, call) -> None:
if call.when == "call":
if call.excinfo is not None and "page" in item.funcargs:
page = item.funcargs["page"]
screenshot_dir = Path(".playwright-screenshots")
screenshot_dir.mkdir(exist_ok=True)
page.screenshot(path=str(screenshot_dir / f"screenshot.png"))
def pytest_addoption(parser):
parser.addoption('--menu-item', default='domains')
parser.addoption('--expected-url', default='https://www.iana.org/domains')
@pytest.fixture
def menu_item(request):
return request.config.getoption('--menu-item')
@pytest.fixture
def expected_url(request):
return request.config.getoption('--expected-url')