Skip to main content

BehaveX extension library to attach images to the test execution report.

Project description

Downloads PyPI version Dependency Status License GitHub last commit

behavex-images

An extension for the BehaveX library that enables attaching images to the generated HTML report.

Installation

pip install behavex-images

Features

  • Attach images to BehaveX HTML reports
  • Support for both binary image data and image files
  • Flexible attachment conditions (always, only on failure, or never)
  • Easy integration with existing BehaveX projects

Usage

The behavex-images library provides four main methods for managing image attachments in BehaveX HTML reports:

1. Attach Image from Binary Data

from behavex_images import image_attachments

image_attachments.attach_image_binary(context, image_binary)
  • context: The BehaveX context object
  • image_binary: Binary data of the image (JPG or PNG)

2. Attach Image from File

from behavex_images import image_attachments

image_attachments.attach_image_file(context, file_path)
  • context: The BehaveX context object
  • file_path: Absolute path to the image file (JPG or PNG)

3. Set Attachment Condition

from behavex_images import image_attachments
from behavex_images.image_attachments import AttachmentsCondition

image_attachments.set_attachments_condition(context, condition)
  • context: The BehaveX context object
  • condition: One of the following AttachmentsCondition values:
    • ALWAYS: Attach images to every report
    • ONLY_ON_FAILURE: Attach images only when a test fails (default)
    • NEVER: Do not attach any images

4. Clean All Attached Images

from behavex_images import image_attachments

image_attachments.clean_all_attached_images(context)
  • context: The BehaveX context object

Examples

Attaching an Image in a Step Definition

from behavex_images import image_attachments

@given('I take a screenshot of the current page')
def step_impl(context):
    image_attachments.attach_image_file(context, 'path/to/screenshot.png')

Using Hooks in environment.py

from behavex_images import image_attachments
from behavex_images.image_attachments import AttachmentsCondition

def before_all(context):
    image_attachments.set_attachments_condition(context, AttachmentsCondition.ONLY_ON_FAILURE)

def after_step(context, step):
    # Assuming you're using Selenium WebDriver
    image_attachments.attach_image_binary(context, context.driver.get_screenshot_as_png())

Sample Report Output

Test Execution Report

Test Execution Report with Images

Test Execution Report Details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

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

behavex_images-3.3.1.tar.gz (956.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behavex_images-3.3.1-py3-none-any.whl (956.0 kB view details)

Uploaded Python 3

File details

Details for the file behavex_images-3.3.1.tar.gz.

File metadata

  • Download URL: behavex_images-3.3.1.tar.gz
  • Upload date:
  • Size: 956.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for behavex_images-3.3.1.tar.gz
Algorithm Hash digest
SHA256 bf296daf33c1591c24eed3970757581095f5ec6f37eec360d789154bd9b9c7fa
MD5 3d8763d6bb3cb69c1030751a0820822d
BLAKE2b-256 12b125d51adda8f88cace299849803c47e6d55a7a29e9cff7979967ced56f0d6

See more details on using hashes here.

File details

Details for the file behavex_images-3.3.1-py3-none-any.whl.

File metadata

  • Download URL: behavex_images-3.3.1-py3-none-any.whl
  • Upload date:
  • Size: 956.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for behavex_images-3.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac8274ac67f956fd78a1b8af54306618e842bc19c26e19b4fe488b58a77f5aea
MD5 e341ac9f5dab60f3f43414b281292254
BLAKE2b-256 5b91d5a49b11110e7d7d768ed381ac818f0e9ef8bd55591e17d0e616c167470b

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