BehaveX Images
raw JSON → 3.3.1 verified Fri May 01 auth: no python
BehaveX extension library to attach images (screenshots) to BehaveX test execution reports. Current version 3.3.1, requires Python >=3.8. Released on PyPI with moderate cadence.
pip install behavex-images Common errors
error ModuleNotFoundError: No module named 'behavex.images' ↓
cause Wrong import path; the module is 'behavex_images'.
fix
Install behavex-images and import as: from behavex_images import BehavexImages
error AttributeError: 'str' object has no attribute 'read' ↓
cause Passing a file path string to context.embed instead of bytes.
fix
Use context.embed(open('screenshot.png', 'rb').read(), 'image/png')
Warnings
gotcha BehavexImages does not need to be instantiated; it's automatically loaded via behave entrypoint. ↓
fix Do not initialize BehavexImages manually; simply import and use context.embed.
deprecated The old import path 'from behavex.images' has been removed. ↓
fix Use 'from behavex_images import BehavexImages'.
gotcha context.embed expects bytes, not file path. Passing a string will raise AttributeError. ↓
fix Use open('screenshot.png', 'rb').read() to get bytes.
Imports
- BehavexImages wrong
from behavex.images import BehavexImagescorrectfrom behavex_images import BehavexImages
Quickstart
from behave import *
from behavex_images import BehavexImages
@given('I take a screenshot')
def step_take_screenshot(context):
driver = context.driver # assume WebDriver
context.embed(driver.get_screenshot_as_png(), 'image/png')