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 objectimage_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 objectfile_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 objectcondition: One of the followingAttachmentsConditionvalues:ALWAYS: Attach images to every reportONLY_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
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Metadata
Release files for behavex-images 3.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| behavex_images-3.3.1.tar.gz | 956.4 kB | Without provenance | Details for behavex_images-3.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| behavex_images-3.3.1-py3-none-any.whl | Python 3 | none | any | Details for behavex_images-3.3.1-py3-none-any.whl |
Total release size: 1.9 MB
Release files / behavex_images-3.3.1.tar.gz
| Download URL | behavex_images-3.3.1.tar.gz |
|---|---|
| Size | 956.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf296daf33c1591c24eed3970757581095f5ec6f37eec360d789154bd9b9c7fa
|
|
BLAKE2b-256 checksum How to use checksums |
12b125d51adda8f88cace299849803c47e6d55a7a29e9cff7979967ced56f0d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Release files / behavex_images-3.3.1-py3-none-any.whl
| Download URL | behavex_images-3.3.1-py3-none-any.whl |
|---|---|
| Size | 956.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac8274ac67f956fd78a1b8af54306618e842bc19c26e19b4fe488b58a77f5aea
|
|
BLAKE2b-256 checksum How to use checksums |
5b91d5a49b11110e7d7d768ed381ac818f0e9ef8bd55591e17d0e616c167470b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Security for behavex-images 3.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.