# Pytest-Playwright E2E Forge — Python Tests That Don't Flake

> Generate pytest-playwright E2E tests the way stable suites are actually built: Python Page Objects, one shared login, semantic locators, zero sleeps — and a repeat-run flake check before anything is called done.

Pytest-Playwright E2E Forge — Python Tests That Don't Flake is a paid AI agent skill on Agensi by Mika Nekote, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $12 (one-time purchase)
- Creator: [Mika Nekote](https://www.agensi.io/creators/mika-nekote)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Version: 1.0
- Last updated: 2026-11-26
- Security: scan passed (2026-11-26); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/pytest-playwright-e2e-forge-python-tests-that-don-t-flake
- Tags: testing, python, playwright, pytest, pytest-playwright, e2e, page-object, flaky-tests

## About this skill

Most Playwright test generators target TypeScript. If your backend is Python — FastAPI, Django, Flask — you end up translating someone else's patterns and inheriting their flakes.

Pytest-Playwright E2E Forge is a skill that makes your agent generate E2E tests natively for pytest-playwright, following the practices that keep suites green:

- Flow selection first. It covers user-critical flows (sign-in, the main transaction, destructive actions, permission boundaries) instead of spraying tests at every page.
- Python Page Objects. One class per screen, locators as properties, user-level actions — generated from a battle-tested template.
- Log in once, not per test. A session-scoped fixture logs in through the UI a single time and reuses Playwright storage_state everywhere else, with an optional second low-privilege account for permission tests.
- Semantic locators, enforced. Role → label → placeholder → text → test id. CSS/XPath chains, generated class names, sleep(), and one-shot state reads are on a reject list the agent must apply.
- Failure evidence built in. Screenshot + browser console log on every failure, plus the exact flags for traces and video.
- Verified, not just generated. The bundled flake_check.py runs every new test N times in separate processes and classifies it stable-pass / stable-fail / FLAKY. A suite isn't "done" until everything delivered is stable-pass.

What's included:
- SKILL.md — The full workflow: flow selection → conftest → Page Objects → tests → anti-flake rules → verification
- assets/conftest_template.py — Drop-in conftest: storage_state auth fixtures (two accounts), console capture, failure artifacts
- assets/page_object_template.py — Page Object template with worked locator examples
- reference/locator-rules.md — Locator priority order + anti-pattern table
- scripts/flake_check.py — Repeat-run flake detector (stdlib only, JSON report)
- examples/ — Complete worked example: login + project-list flow

Who it's for: Python web teams and solo developers who want browser tests that still pass next month — especially if your E2E layer is currently empty, Selenium-era, or a pile of translated TypeScript examples.

Requirements: Python 3.10+, pytest, playwright, pytest-playwright; a reachable non-production environment and a dedicated test account; an agent that can read SKILL.md-style skill packages.

## Requires

- Python

## Known limitations

Sync API only. No support for visual regression or live data feeds. Requires environment variables for credentials and a dedicated test account.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Pytest-Playwright E2E Forge — Python Tests That Don't Flake skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Is this a prompt pack?

No. It's a workflow skill plus working code assets.

### Does it work with Django/Flask, or only FastAPI?

Any Python web app reachable over HTTP with a login flow.

### Why not just use Playwright's codegen?

Codegen records CSS-heavy, sleep-prone scripts. This skill generates maintainable Page Objects with semantic locators and then proves stability by running each test repeatedly.

### Can it run in CI?

Yes. Headless-friendly, credentials from environment variables, flake_check.py exits non-zero on flaky tests.

### Does it support async Playwright or TypeScript?

No — deliberately Python sync-API pytest-playwright only.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
