Metadata-Version: 2.5
Name: reportforge-playwright-pdf
Version: 0.33.2
Summary: Designed PDF reports for Playwright pytest runs: minimal, detailed, and executive templates.
Project-URL: Homepage, https://reportforge.org
Project-URL: Documentation, https://reportforge.org/docs/python
Project-URL: Changelog, https://reportforge.org/changelog
Author: ReportForge
License: Copyright (c) 2026 ReportForge
        
        Elastic License 2.0
        
        URL: https://www.elastic.co/licensing/elastic-license
        
        ## Acceptance
        
        By using the software, you agree to all of the terms and conditions below.
        
        ## Copyright License
        
        The licensor grants you a non-exclusive, royalty-free, worldwide,
        non-sublicensable, non-transferable license to use, copy, distribute, make
        available, and prepare derivative works of the software, in each case subject to
        the limitations and conditions below.
        
        ## Limitations
        
        You may not provide the software to third parties as a hosted or managed
        service, where the service provides users with access to any substantial set of
        the features or functionality of the software.
        
        You may not move, change, disable, or circumvent the license key functionality
        in the software, and you may not remove or obscure any functionality in the
        software that is protected by the license key.
        
        You may not alter, remove, or obscure any licensing, copyright, or other notices
        of the licensor in the software. Any use of the licensor’s trademarks is subject
        to applicable law.
        
        ## Patents
        
        The licensor grants you a license, under any patent claims the licensor can
        license, or becomes able to license, to make, have made, use, sell, offer for
        sale, import and have imported the software, in each case subject to the
        limitations and conditions in this license. This license does not cover any
        patent claims that you cause to be infringed by modifications or additions to
        the software. If you or your company make any written claim that the software
        infringes or contributes to infringement of any patent, your patent license for
        the software granted under these terms ends immediately. If your company makes
        such a claim, your patent license ends immediately for work on behalf of your
        company.
        
        ## Notices
        
        You must ensure that anyone who gets a copy of any part of the software from you
        also gets a copy of these terms.
        
        If you modify the software, you must include in any modified copies of the
        software prominent notices stating that you have modified the software.
        
        ## No Other Rights
        
        These terms do not imply any licenses other than those expressly granted in
        these terms.
        
        ## Termination
        
        If you use the software in violation of these terms, such use is not licensed,
        and your licenses will automatically terminate. If the licensor provides you
        with a notice of your violation, and you cease all violation of this license no
        later than 30 days after you receive that notice, your licenses will be
        reinstated retroactively. However, if you violate these terms after such
        reinstatement, any additional violation of these terms will cause your licenses
        to terminate automatically and permanently.
        
        ## No Liability
        
        *As far as the law allows, the software comes as is, without any warranty or
        condition, and the licensor will not be liable to you for any damages arising
        out of these terms or the use or nature of the software, under any kind of
        legal claim.*
        
        ## Definitions
        
        The **licensor** is the entity offering these terms, and the **software** is the
        software the licensor makes available under these terms, including any portion
        of it.
        
        **you** refers to the individual or entity agreeing to these terms.
        
        **your company** is any legal entity, sole proprietorship, or other kind of
        organization that you work for, plus all organizations that have control over,
        are under the control of, or are under common control with that
        organization. **control** means ownership of substantially all the assets of an
        entity, or the power to direct its management and policies by vote, contract, or
        otherwise. Control can be direct or indirect.
        
        **your licenses** are all the licenses granted to you for the software under
        these terms.
        
        **use** means anything you do with the software requiring one of your licenses.
        
        **trademark** means trademarks, service marks, and similar rights.
License-File: LICENSE
Keywords: pdf,playwright,pytest,pytest-playwright,report,reportforge,test-report
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: playwright>=1.40
Requires-Dist: pytest>=7.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Description-Content-Type: text/markdown

# reportforge-playwright-pdf

Designed PDF reports for Playwright pytest runs. Three templates cover three audiences: minimal for PR checks, detailed for QA deep dives, executive for stakeholder reviews.

Same product as the npm reporter [`@reportforge/playwright-pdf`](https://www.npmjs.com/package/@reportforge/playwright-pdf), the .NET logger `ReportForge.Playwright.Pdf`, and the Cypress plugin `@reportforge/cypress-pdf`. One subscription issues a key for each runner, so Python gets its own `RFPY-…` key and its own allowance of 25 machines, separate from the ones your other suites use.

---

## Install

```bash
pip install reportforge-playwright-pdf
python -m playwright install chromium
```

Requires Python 3.10 or later and `playwright`. The plugin reuses the Node runtime and the Chromium that Playwright for Python already installs, so there is no npm install and no second browser download.

## Quick start

```bash
export RF_LICENSE_KEY=RFPY-XXXX-XXXX-XXXX-XXXX
pytest --pdf
```

The PDF lands at `playwright-report/{date}-report.pdf` by default, and the path is printed in the terminal summary when it is written.

**Your tests always run in full.** A licensing problem, a missing browser, or an engine error never fails your suite: the plugin logs one warning and skips the PDF. The pytest exit code is decided by your tests alone.

### The plugin is inert until you switch it on

Installing the package changes nothing about a plain `pytest` run. It activates on any one of:

| How | Use it for |
|---|---|
| `pytest --pdf` | One-off local runs |
| `RF_PDF=1 pytest` | CI, without touching the command |
| `enabled = true` under `[tool.reportforge]` | Project default, every run |

## Configuration

Options use the reporter's camelCase names, unchanged. They are passed to the report engine and validated there by the **same schema the npm reporter uses**, so the two ecosystems cannot drift on what an option means.

### Precedence

Lowest to highest, so a CLI flag always wins:

1. `--pdf-options FILE.json`: the full options object
2. `[tool.reportforge]` in `pyproject.toml`: your project defaults
3. Individual `--pdf-*` flags: this run only

### Flags

| Flag | Effect |
|---|---|
| `--pdf` | Generate the report after the run |
| `--pdf-output PATH` | Output path; `{date}`, `{branch}`, `{status}` tokens are expanded |
| `--pdf-template ID[,ID]` | `minimal`, `detailed`, or `executive`; pass several to emit several reports |
| `--pdf-options JSON_PATH` | JSON file holding the full options object |
| `--pdf-engine JS_PATH` | Point at a different engine build (development and CI; also `RF_ENGINE_PATH`) |

```bash
pytest --pdf --pdf-template=executive --pdf-output="reports/{date}-report.pdf"
```

### Project defaults

```toml
[tool.reportforge]
enabled = true
template = "detailed"
outputFile = "reports/{date}-{branch}-report.pdf"
projectName = "Checkout suite"
slowTestThreshold = 5000

[tool.reportforge.capture]
evidence = true

[tool.reportforge.live]
enabled = true

[tool.reportforge.notify.slack]
webhookUrl = "https://hooks.slack.com/services/..."
```

Full option reference: [reportforge.org/docs/configuration](https://reportforge.org/docs/configuration). Python specifics: [reportforge.org/docs/python](https://reportforge.org/docs/python).

> **Add `.reportforge/` to your `.gitignore`.** The plugin writes your resolved options there to hand them to the report engine, so a `licenseKey` set in `pyproject.toml` rather than the environment would land in a file inside your project. The same applies to `pdfPassword`.

## How your results are reported

pytest has more outcomes than a pass/fail report implies. Each is mapped deliberately rather than flattened:

| pytest outcome | Report status | Notes |
|---|---|---|
| pass | passed | |
| fail | failed | |
| setup or teardown error | failed | annotated as a setup/teardown error, so it is not read as a test defect |
| skip | skipped | |
| `xfail` that failed | failed | annotated `xfail`; the expected outcome, not a regression |
| `xpass` | passed | annotated `xpass`; passing when it was expected to fail is worth seeing |
| rerun then pass | **flaky** | with the full attempt history (`pytest-rerunfailures`) |
| reruns exhausted | failed | every attempt recorded |
| `pytest-timeout` kill | timed out | matched on the framework's own wording |

**Markers become tags.** `@pytest.mark.smoke` shows as `@smoke` in the report. pytest's own structural markers (`parametrize`, `usefixtures`, `skipif`, `skip`, `xfail`, `asyncio`) are excluded, since they describe the harness rather than the test.

**pytest-xdist is supported.** Results are accumulated on the controller, so a `-n auto` run produces one report rather than one per worker.

## What you get

- Pass, fail, flaky, timeout and skip KPIs, suite breakdown, charts, and a release recommendation
- Failure deep dive with error text, on-device ML failure clustering that groups failures by likely root cause, and screenshots from `--screenshot=only-on-failure`
- Trace archives and videos from `--tracing` / `--video` feed the defect log's evidence links; pair with `evidenceUrlTemplate` for clickable CI links
- Run history trend and a run-over-run diff showing what newly failed, what was fixed, and what is still failing
- Notifications to Slack, Teams, Discord, or email after the run
- Display redaction and AES-256 PDF encryption when you need them
- Passing `--browser` more than once splits the report into one project per browser and unlocks the cross-browser comparison section

## Live runs

Set `[tool.reportforge.live] enabled = true` and the run streams to a shareable watch page as tests finish, the same page the Node.js reporter produces. The watch URL is printed at the start of the run and repeated in the terminal summary.

Streaming is best-effort by design: if the relay is unreachable the run continues and the PDF renders exactly as it would have. Step trees stay Node.js-only today.

## CI

```yaml
- run: pip install reportforge-playwright-pdf
- run: python -m playwright install --with-deps chromium
- run: pytest --pdf
  env:
    RF_LICENSE_KEY: ${{ secrets.RF_LICENSE_KEY_PYTHON }}
```

Store the `RFPY-…` key as a secret. Every CI machine that runs the suite takes one of the licence's 25 machine slots; a slot frees itself automatically after 30 days without a run, so ephemeral runners recycle on their own.

## Troubleshooting

**No PDF and one warning about the licence.** Expected behaviour when the key is missing, wrong for this runner, or the subscription is inactive. Check that `RF_LICENSE_KEY` holds the `RFPY-…` key: a key for another runner is refused with a message naming both sides.

**"No such option: --pdf".** The plugin did not load. Confirm the install landed in the same environment pytest runs from.

**Nothing happens on a plain `pytest`.** By design. See the activation table above.

**Chromium or Node cannot be found.** The plugin looks where Playwright for Python puts them. Override with `PLAYWRIGHT_BROWSERS_PATH`, `PUPPETEER_EXECUTABLE_PATH`, or `RF_NODE_PATH` if your environment relocates them.

## License

[Elastic License 2.0](https://www.elastic.co/licensing/elastic-license). A paid subscription is required to generate PDFs: [reportforge.org/pricing](https://reportforge.org/pricing).
