#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...

Комментарии • 16

  • @arsiddilip6748
    @arsiddilip6748 5 месяцев назад

    what about slugify module ?
    I am getting error on slugify line

  • @Canadoloteluguammai
    @Canadoloteluguammai Год назад

    How to add looping I wanted to execute test suite 10 times and generate the html report for the same

  • @user-nm8yp6ke9v
    @user-nm8yp6ke9v 7 месяцев назад

    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?

    • @user-nm8yp6ke9v
      @user-nm8yp6ke9v 7 месяцев назад

      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')

  • @lakshmikanthcherukuri1321
    @lakshmikanthcherukuri1321 Год назад +1

    Please do video on POM FRAMEWORK IN PLAY WRIGHT WITH PYTHON

  • @zhengdiao3494
    @zhengdiao3494 Год назад

    hi,nice,Have you tried using allure?

  • @libinscuk
    @libinscuk Год назад +1

    Can you share the github link for the code please?

    • @automationneemo
      @automationneemo  Год назад

      Code is given in the description. Will share the github link

    • @automationneemo
      @automationneemo  Год назад

      Github link is added in description

    • @libinscuk
      @libinscuk Год назад +1

      @@automationneemo Thanks a ton. Appreciate your help :)

  • @jestinkjoseph8549
    @jestinkjoseph8549 Год назад +1

    can you please share how to pass/enter data dyanamically

  • @seniorqa_auto5367
    @seniorqa_auto5367 Год назад

    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
    )))