#82 Playwright with Python | Attach Screenshot in Pytest HTML Report on Failure with Playwright
HTML-код
- Опубликовано: 10 сен 2024
- #playwright
#python
#pytest
In this video we learned about
How to attach screenshot in Pytest HTML report on Failure with Playwright
How to generate Pytest HTML report along Screenshots with Playwright
Pytest Documenation:
pytest-html.re...
Command:
pytest -s --headed .\test_01_sauce_demo.py --html=myreport2.html --self-c
ontained-html --capture=tee-sy
Code snippet attaching Screenshots:
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin("html")
outcome = yield
screen_file = ''
report = outcome.get_result()
extra = getattr(report, "extra", [])
if report.when == "call":
xfail = hasattr(report, "wasxfail")
if report.failed or xfail and "page" in item.funcargs:
page = item.funcargs["page"]
screenshot_dir = Path("screenshots")
screenshot_dir.mkdir(exist_ok=True)
screen_file = str(screenshot_dir / f"{slugify(item.nodeid)}.png")
page.screenshot(path=screen_file)
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
Github link - github.com/aut...
what about slugify module ?
I am getting error on slugify line
How to add looping I wanted to execute test suite 10 times and generate the html report for the same
Thank you so much! I have question. What if I have more than one conf function. For logged and unlogged user. Can you give me advice?
Becouse if I type list with my conf function I got: INTERNALERROR> page = item.funcargs["login_Set_up", "set_up"]
INTERNALERROR> ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> KeyError: ('login_Set_up', 'set_up')
Please do video on POM FRAMEWORK IN PLAY WRIGHT WITH PYTHON
Ok. Will do.
hi,nice,Have you tried using allure?
Can you share the github link for the code please?
Code is given in the description. Will share the github link
Github link is added in description
@@automationneemo Thanks a ton. Appreciate your help :)
can you please share how to pass/enter data dyanamically
I have added one video on Data Provider. Please check it out
@@automationneemo ok
@@automationneemo thank you
Hi! Excuse me ) In
"Command:
pytest -s --headed .\test_01_sauce_demo.py --html=myreport2.html --self-c
ontained-html --capture=tee-sy"
you should add "s"
tee-sys
)))