{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"playwright-python","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Playwright Python AI test generation instructions based on official documentation.'\napplyTo: '**'\n---\n\n# Playwright Python Test Generation Instructions\n\n## Test Writing Guidelines\n\n### Code Quality Standards\n- **Locators**: Prioritize user-facing, role-based locators (get_by_role, get_by_label, get_by_text) for resilience and accessibility.\n- **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.\n- **Timeouts**: Rely on Playwright's built-in auto-waiting mechanisms. Avoid hard-coded waits or increased default timeouts.\n- **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.\"\n\n### Test Structure\n- **Imports**: Every test file should begin with from playwright.sync_api import Page, expect.\n- **Fixtures**: Use the page: Page fixture as an argument in your test functions to interact with the browser page.\n- **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.\n\n### File Organization\n- **Location**: Store test files in a dedicated tests/ directory or follow the existing project structure.\n- **Naming**: Test files must follow the test_\u003cfeature-or-page\u003e.py naming convention to be discovered by Pytest.\n- **Scope**: Aim for one test file per major application feature or page.\n\n## Assertion Best Practices\n- **Element Counts**: Use expect(locator).to_have_count() to assert the number of elements found by a locator.\n- **Text Content**: Use expect(locator).to_have_text() for exact text matches and expect(locator).to_contain_text() for partial matches.\n- **Navigation**: Use expect(page).to_have_url() to verify the page URL.\n- **Assertion Style**: Prefer `expect` over `assert` for more reliable UI tests.\n\n\n## Example\n\n```python\nimport re\nimport pytest\nfrom playwright.sync_api import Page, expect\n\n@pytest.fixture(scope=\"function\", autouse=True)\ndef before_each_after_each(page: Page):\n    # Go to the starting url before each test.\n    page.goto(\"https://playwright.dev/\")\n\ndef test_main_navigation(page: Page):\n    expect(page).to_have_url(\"https://playwright.dev/\")\n\ndef test_has_title(page: Page):\n    # Expect a title \"to contain\" a substring.\n    expect(page).to_have_title(re.compile(\"Playwright\"))\n\ndef test_get_started_link(page: Page):\n    page.get_by_role(\"link\", name=\"Get started\").click()\n    \n    # Expects page to have a heading with the name of Installation.\n    expect(page.get_by_role(\"heading\", name=\"Installation\")).to_be_visible()\n```\n\n## Test Execution Strategy\n\n1. **Execution**: Tests are run from the terminal using the pytest command.\n2. **Debug Failures**: Analyze test failures and identify root causes\n","description":"Playwright Python AI test generation instructions based on official documentation.","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/playwright-python.instructions.md"},"manifest":{}},"content_hash":[125,219,77,196,13,101,78,200,183,204,194,148,200,234,78,86,223,145,46,49,53,150,6,13,209,63,109,54,211,4,138,25],"trust_level":"unsigned","yanked":false}
