Skip to main content

Test case fails,take a screenshot,save it,attach it to the allure

Project description

pytest-failed-screenshot: pytest plugin

For UI automation test cases using selenium and appium, screenshots are saved when they fail, and are attached to the report when allure is used

Support helium, the webdriver process cannot be killed within a use case


pip install pytest-failed-screenshot


command line:pytest --screenshot={on:off} --screenshot_path={on:off:absolute path}

    • options:

    • screenshot: Used to open plugin, default “off”

    • screenshot_path:
      • off: The default is ‘off’.The screenshot will not be saved and will only be attached to the allure report.

      • on: The screenshots will be saved to the “./screenshot/%Y-%m-%d/” directory in the root path of the project. If the directory has historical screenshots, the historical screenshots will be archived, moved to the “./screenshot/history/%Y-%m-%d/{times}” directory, and attached to the allure report

      • Absolute path: The screenshot will be saved in that path and attached to the report.


The driver instances of selenium and appium must be transferred by a fixture.

import pytest
from selenium import webdriver

def init_driver():
    driver = webdriver.Chrome()
    yield driver

def test_login_success(init_driver):
    assert False

# helium demo
def init_helium():
    yield None

def test_helium_demo():
    # The webdriver process cannot be killed within a use case
    assert False

command: pytest --screenshot=on --screenshot_path=on

tip: Support the use of pytest-xdist together



Support helium for screenshots , solve the problem


Update the readme and add demo

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_failed_screenshot-1.0.2.tar.gz (3.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page