Trace viewer and step-by-step debugger for Behave BDD.
Project description
behave-trace
Trace viewer and step-by-step debugger for Behave BDD.
Captures execution data (steps, statuses, durations, screenshots, DOM snapshots, logs) and visualizes them in a Playwright-inspired web viewer with timeline, filmstrip, and per-step detail tabs.
Quickstart
# 1. Install
pip install behave-trace
# 2. Capture — run Behave with the formatter
behave --format behave-trace -o trace.json
# 3. Visualize — open the viewer
behave-trace show trace.json
The viewer opens in your browser at http://127.0.0.1:<port> with a dark-themed
SPA showing features, scenarios, steps, screenshots, and errors.
How it works
┌──────────┐ ┌──────────────┐ ┌───────────┐ ┌──────────────┐
│ Behave │────▶│ Formatter │────▶│ Serializer │────▶│ trace.json │
│ runner │ │ (collector) │ │ (JSON) │ │ │
└──────────┘ └──────────────┘ └───────────┘ └──────┬───────┘
│
┌────────────────────────────────────────┘
▼
┌──────────────┐ ┌──────────────────┐
│ behave-trace │────▶│ Browser SPA │
│ show │ │ (Alpine.js) │
│ (HTTP server)│ │ Dark theme │
└──────────────┘ └──────────────────┘
Two-phase model (like Playwright Trace Viewer):
-
Capture — The
TraceFormatterhooks into Behave's formatter API and collects execution events into aTracedata model. Attachments (screenshots, DOM, logs) are captured viaattach_screenshot(),attach_dom(), andlog()helpers inenvironment.py. -
Visualize —
behave-trace showloads the trace JSON, starts a local HTTP server (stdlib only, no dependencies), and opens the viewer SPA in a browser.
Capturing attachments
Add to your environment.py:
from behave_trace import attach_screenshot, attach_dom, log
def after_step(context, step):
if step.status == "failed":
attach_screenshot(context, context.driver, name="failure.png")
attach_dom(context, context.driver, name="dom.html")
log(context, f"URL at failure: {context.driver.current_url}")
The viewer will show screenshots in the filmstrip and detail tabs, with before/after DOM snapshot toggling.
CLI
# Show trace in browser
behave-trace show trace.json
# Show on specific port, don't open browser
behave-trace show trace.json --port 8080 --no-browser
# Version
behave-trace --version
Development
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Lint
ruff check behave_trace/ tests/
ruff format --check behave_trace/ tests/
# Type check
mypy behave_trace/
# Unit + integration tests
pytest tests/ -v
# E2E tests (meta: Behave testing Behave)
behave tests/e2e/
# Build
python -m build
Project structure
behave_trace/
__init__.py # Public API, formatter registration
__main__.py # python -m behave_trace entry point
formatter.py # Behave formatter (TraceFormatter)
collector.py # Event collector → Trace model
models.py # Dataclasses: Trace, Feature, Scenario, Step, etc.
serializer.py # JSON load/save
attach.py # Attachment helpers (screenshot, DOM, log)
utils.py # Utilities (format_duration, safe_str)
cli/
app.py # argparse CLI with `show` subcommand
viewer/
server.py # stdlib HTTP server (ThreadingHTTPServer)
browser.py # Browser opener (Chrome app mode)
assets/
index.html # SPA shell (Alpine.js from CDN)
css/viewer.css # Dark theme styles
js/viewer.js # Alpine.js component logic
License
MIT — see 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file behave_trace-1.0.0.tar.gz.
File metadata
- Download URL: behave_trace-1.0.0.tar.gz
- Upload date:
- Size: 55.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69c49d05ffa399e7bc84c749dd242bedc6081bd3e0db35f46936e70a85c885d0
|
|
| MD5 |
a29449f884747952fa2c128769bd41b3
|
|
| BLAKE2b-256 |
844adfcd10d32d34e3b88bed4625d063216e458eb908118e9f667d55ffce979e
|
Provenance
The following attestation bundles were made for behave_trace-1.0.0.tar.gz:
Publisher:
release.yml on MathiasPaulenko/behave-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_trace-1.0.0.tar.gz -
Subject digest:
69c49d05ffa399e7bc84c749dd242bedc6081bd3e0db35f46936e70a85c885d0 - Sigstore transparency entry: 2334140520
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-trace@c7a175454d679904a59c786487dc3d4f43ea9759 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c7a175454d679904a59c786487dc3d4f43ea9759 -
Trigger Event:
push
-
Statement type:
File details
Details for the file behave_trace-1.0.0-py3-none-any.whl.
File metadata
- Download URL: behave_trace-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdb359df441c19a39467e9babbc876370144208556306188dde9339d19c2bc27
|
|
| MD5 |
7be6dcdec69bd757a4643aff1807f9aa
|
|
| BLAKE2b-256 |
800d170578f4b5236fbc21a244fda2964b9c62b9f559a72cadbcabed1ea53dca
|
Provenance
The following attestation bundles were made for behave_trace-1.0.0-py3-none-any.whl:
Publisher:
release.yml on MathiasPaulenko/behave-trace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_trace-1.0.0-py3-none-any.whl -
Subject digest:
bdb359df441c19a39467e9babbc876370144208556306188dde9339d19c2bc27 - Sigstore transparency entry: 2334140564
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-trace@c7a175454d679904a59c786487dc3d4f43ea9759 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c7a175454d679904a59c786487dc3d4f43ea9759 -
Trigger Event:
push
-
Statement type: