A Python Screenplay pattern framework with cinematic test reporting
Project description
Screenwright
A Python Screenplay pattern framework with cinematic test reporting.
Screenwright brings the Screenplay pattern to Python testing. Actors perform Tasks, exercise Abilities through Interactions, and verify outcomes by asking Questions -- all while generating cinematic HTML reports with Material Design 3 dark neon theming.
Key Features
- Screenplay Pattern Engine -- Actor, Task, Interaction, Question, Ability, and Fact primitives with full event sourcing
- pytest-bdd Integration -- Auto-registered plugin with Stage and Actor fixtures, zero configuration required
- Cinematic HTML Reports -- Dashboard overview with summary cards, feature lists, and scenario rows; theatre-style scenario presentations with actor entrances, ability badges, interaction arrows, and narration subtitles
- Material Design 3 Theming -- YAML-based theme configuration with tonal palette generation, neon glow effects, and customizable personas
- Typed Domain Events -- 17 frozen dataclass events with JSON serialization, enabling full traceability of test execution
- Fully Typed -- py.typed marker with strict mypy compliance
Installation
pip install screenwright
For development:
pip install screenwright[dev]
Quick Start
1. Write a feature file
# features/search.feature
Feature: Web Search
Scenario: Search for a term
Given Ali can browse the web
When Ali searches for "Screenplay pattern"
Then Ali should see results containing "Screenplay"
2. Define step implementations using the Screenplay pattern
# tests/step_defs/test_search_steps.py
from pytest_bdd import scenario, given, when, then, parsers
from screenwright import Actor, Ability, Interaction, Question, task
# -- Abilities --
class BrowseTheWeb(Ability):
def __init__(self, driver):
self.driver = driver
@staticmethod
def using(driver):
return BrowseTheWeb(driver)
# -- Interactions --
class SearchFor(Interaction):
def __init__(self, term):
self.term = term
@staticmethod
def the_term(term):
return SearchFor(term)
def perform_as(self, actor):
driver = actor.ability_to(BrowseTheWeb).driver
driver.find_element("name", "q").send_keys(self.term)
driver.find_element("name", "q").submit()
# -- Questions --
class SearchResults(Question):
def answered_by(self, actor):
driver = actor.ability_to(BrowseTheWeb).driver
return driver.find_element("id", "results").text
# -- Steps --
@scenario("../features/search.feature", "Search for a term")
def test_search():
pass
@given("Ali can browse the web")
def ali_can_browse(actor, stage):
ali = stage.actor_named("Ali")
ali.who_can(BrowseTheWeb.using(create_driver()))
@when(parsers.parse('Ali searches for "{term}"'))
def ali_searches(stage, term):
ali = stage.shines_spotlight_on("Ali")
ali.attempts_to(SearchFor.the_term(term))
@then(parsers.parse('Ali should see results containing "{text}"'))
def ali_sees_results(stage, text):
ali = stage.shines_spotlight_on("Ali")
ali.should_see_that(SearchResults(), lambda answer: text in answer)
3. Run tests
pytest tests/ --screenwright-report=report.html
Open report.html to view the cinematic test report.
Documentation
Full documentation is available at screenwright.dev.
License
Screenwright is released under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
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 screenwright-0.1.0b1.tar.gz.
File metadata
- Download URL: screenwright-0.1.0b1.tar.gz
- Upload date:
- Size: 92.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cdaaa55e71fd7315c9934f0d4c151a6fff065932db8b263477a56a06674752c
|
|
| MD5 |
3cc67cea27dbd5560b573ff0af2e0214
|
|
| BLAKE2b-256 |
384c26b20021b503652ee1889906f950c125d70bc09c9275685e7f8e6d901121
|
File details
Details for the file screenwright-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: screenwright-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 83.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc9d420920e58a0dd362b815628920f12d1e1f49ebd7a9b1ff41864c48d6f3f2
|
|
| MD5 |
a58fd055b71401113b362a20f33f5aea
|
|
| BLAKE2b-256 |
9fe32a1e438fbd5c001ceb366ee6da8bf39c5a31325040ccd707c9bd42c09eff
|