Technology Sharing

Use pytest-playwright to take screenshots and record videos and add them to Allure reports

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

1. Dependence on the environment

python, version3.9.5
pytest-playwright, version==0.5.1
allure-pytest, version
2.13.5
pytest, version6.2.5
allure, version
2.22.0

pytest-playwrightThe following command line parameters are supported:

Playwright:
  --browser={chromium,firefox,webkit}
                        Browser engine which should be used
  --headed              Run tests in headed mode.
  --browser-channel=BROWSER_CHANNEL
                        Browser channel to be used.
  --slowmo=SLOWMO       Run tests with slow mo
  --device=DEVICE       Device to be emulated.
  --output=OUTPUT       Directory for artifacts produced by tests, defaults to test-results.
  --tracing={on,off,retain-on-failure}
                        Whether to record a trace for each test.
  --video={on,off,retain-on-failure}
                        Whether to record video for each test.
  --screenshot={on,off,only-on-failure}
                        Whether to automatically capture a screenshot after each test.
  --full-page-screenshot
                        Whether to take a full page screenshot

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

2. Parameter Description

pytest-playwright These 3 plugin parameters are used for screenshots, screen recording and tracking:

  • --tracing Whether to record a trace for each test.onofforretain-on-failure(default value:off)。
  • --video Whether to record video for each test.onofforretain-on-failure(default value:off)。
  • --