playwright-python
Playwright Python AI test generation instructions based on official documentation. Use when writing or reviewing Playwright tests in Python.
Best use case
playwright-python is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Playwright Python AI test generation instructions based on official documentation. Use when writing or reviewing Playwright tests in Python.
Teams using playwright-python should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/playwright-python/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How playwright-python Compares
| Feature / Agent | playwright-python | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Playwright Python AI test generation instructions based on official documentation. Use when writing or reviewing Playwright tests in Python.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Playwright Python Test Generation Instructions
## Test Writing Guidelines
### Code Quality Standards
- **Locators**: Prioritize user-facing, role-based locators (get_by_role, get_by_label, get_by_text) for resilience and accessibility.
- **Assertions**: Use auto-retrying web-first assertions via the expect API (e.g., expect(page).to_have_title(...)). Avoid expect(locator).to_be_visible() unless specifically testing for a change in an element's visibility, as more specific assertions are generally more reliable.
- **Timeouts**: Rely on Playwright's built-in auto-waiting mechanisms. Avoid hard-coded waits or increased default timeouts.
- **Clarity**: Use descriptive test titles (e.g., def test_navigation_link_works():) that clearly state their intent. Add comments only to explain complex logic, not to describe simple actions like "click a button."
### Test Structure
- **Imports**: Every test file should begin with from playwright.sync_api import Page, expect.
- **Fixtures**: Use the page: Page fixture as an argument in your test functions to interact with the browser page.
- **Setup**: Place navigation steps like page.goto() at the beginning of each test function. For setup actions shared across multiple tests, use standard Pytest fixtures.
### File Organization
- **Location**: Store test files in a dedicated tests/ directory or follow the existing project structure.
- **Naming**: Test files must follow the test_<feature-or-page>.py naming convention to be discovered by Pytest.
- **Scope**: Aim for one test file per major application feature or page.
## Assertion Best Practices
- **Element Counts**: Use expect(locator).to_have_count() to assert the number of elements found by a locator.
- **Text Content**: Use expect(locator).to_have_text() for exact text matches and expect(locator).to_contain_text() for partial matches.
- **Navigation**: Use expect(page).to_have_url() to verify the page URL.
- **Assertion Style**: Prefer `expect` over `assert` for more reliable UI tests.
## Example
```python
import re
import pytest
from playwright.sync_api import Page, expect
@pytest.fixture(scope="function", autouse=True)
def before_each_after_each(page: Page):
# Go to the starting url before each test.
page.goto("https://playwright.dev/")
def test_main_navigation(page: Page):
expect(page).to_have_url("https://playwright.dev/")
def test_has_title(page: Page):
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
def test_get_started_link(page: Page):
page.get_by_role("link", name="Get started").click()
# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()
```
## Test Execution Strategy
1. **Execution**: Tests are run from the terminal using the pytest command.
2. **Debug Failures**: Analyze test failures and identify root causesRelated Skills
python-mcp-expert
Expert assistant for developing Model Context Protocol (MCP) servers in Python. Use when creating, debugging, or optimizing MCP servers with FastMCP, tools, resources, and prompts.
python-conventions
Python coding conventions and guidelines including PEP 8, type hints, docstrings, and testing standards. Automatically applied when working with Python files.
python-mcp-server
Instructions for building Model Context Protocol (MCP) servers using the Python SDK. Provides patterns, best practices, and code examples for FastMCP, tools, resources, prompts, and transports.
python-mcp-server-generator
Generate a complete MCP server project in Python with tools, resources, and proper configuration. Use when scaffolding a new MCP server from scratch.
microsoft-agent-framework-python
Create, update, refactor, explain or work with code using the Python version of Microsoft Agent Framework. Use when working with AI agents, workflows, or migrating from Semantic Kernel or AutoGen.
worklog
Update worklog files by moving tasks between todo/doing/done states. Use when recording task progress, starting new work, or marking tasks complete. Requires explicit arguments: worklog [done|doing|todo] [description].
template-proposal-review
Review proposal files in localdocs/localdocs/proposals/ and decide whether to apply them to the upstream python-project-template repository. Use when evaluating proposals generated by template-upstream, deciding which ones to accept or reject, and applying accepted ones to the template repo. Triggers on: "proposal 검토", "제안 검토", "template에 반영할지", "proposals 리뷰", "upstream 반영 결정".
template-downstream
Update .claude/, .mcp.json, and .pre-commit-config.yaml from the upstream python-project-template repository into the current project. Only files that exist upstream are updated — project-only files are never deleted. Use when pulling latest tooling, rules, hooks, or skills from the canonical template into this project. Triggers on: "템플릿 최신화", "template sync", "upstream 반영", "template 업데이트".
template-broadcast
Apply template-downstream to all registered downstream projects in bulk, one project at a time. Use when you want to push the latest .claude/, .mcp.json, or .pre-commit-config.yaml to every project at once. Triggers on: "일괄 배포", "전체 프로젝트에 내려보내기", "모든 프로젝트 업데이트", "broadcast template", "bulk sync".
tdd
Test-Driven Development workflow. Use for ALL code changes - features, bug fixes, refactoring. TDD is non-negotiable.
sparks-create
Apply the 13 thinking tools from "Sparks of Genius" (생각의 탄생) to reframe any problem through creative, cross-disciplinary lenses. Use when conventional analysis falls short, when you need a fresh creative angle, or when the problem spans multiple domains.
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.