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

install

pip install pytest-failed-screenshot

Usage

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.

Demo

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

import pytest
from selenium import webdriver


@pytest.fixture()
def init_driver():
    driver = webdriver.Chrome()
    yield driver
    driver.close()
    driver.quit()


def test_login_success(init_driver):
    init_driver.get("https://github.com/fungaegis/pytest-failed-screenshot")
    assert False

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

tip: Support the use of pytest-xdist together

archive
allure

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.0.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file pytest_failed_screenshot-1.0.0.tar.gz.

File metadata

  • Download URL: pytest_failed_screenshot-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.0

File hashes

Hashes for pytest_failed_screenshot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9f0d735ad19e0849900a4369e83fee98f280010dda32a4cb25d61b1060e2a639
MD5 637851d774520ec41b24d924776fa2dd
BLAKE2b-256 3fce53d3c5e2d0aeb7a86c9c3cd1083b90810f732e47e82013e3b2a2f9b5db50

See more details on using hashes here.

Supported by

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