tests/test_homepage.py::test_homepage[Браузер: chrome] Исключение при создании снимка экрана: 'module ' объект не может быть вызван
Это мой HTML-отчет

Вот как я настройте мой conftest.py, чтобы добавить снимок экрана с ошибкой в pytest-html. Благодарим всех за вашу помощь. Я застрял в этом разделе. Спасибо
#conftest.py
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
outcome._result.description = item.function.__doc__
report = outcome.get_result()
report._testid = item.get_closest_marker("test_id").args[0]
setattr(report, "duration_formatter", "%M:%S.%f")
pytest_html = item.config.pluginmanager.getplugin("html")
timestamp = datetime.now().strftime('%H-%M-%S')
screen_file = ''
extra = getattr(report, "extra", [])
if report.when == 'call':
try:
if report.failed and "browser" in item.funcargs:
browser = item.funcargs["browser"]
screenshot_dir = os.path('screenshots/')
screenshot_dir.os.mkdir(exist_ok=True)
screen_file = str(screenshot_dir / f"{slugify(item.nodeid)}{timestamp}.png")
browser.screenshot(path=screen_file)
xfail = hasattr(report, "wasxfail")
if (report.skipped and xfail) or (report.failed and not xfail):
# add the screenshots to the html report
extra.append(pytest_html.extras.png(screen_file))
report.extra = extra
except Exception as e:
print('Exception while screenshot creation: {}'.format(e))
#this is my test
@pytest.mark.test_id("3")
def test_homepage(browser):
"""Asserting the Title of the Login Page"""
#Initiate the login
try:
loginToApp = LoginPage(browser)
loginToApp.login(username, password)
except Exception as e:
pass
#Verify title
homepage = HomePage(browser)
hompeage_Title = homepage.home_page()
assert 'Swag Labs' != hompeage_Title
time.sleep(3)
Подробнее здесь: https://stackoverflow.com/questions/792 ... t-callable