{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"playwright-dotnet","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Playwright .NET test generation instructions'\napplyTo: '**'\n---\n\n# Playwright .NET Test Generation Instructions\n\n## Test Writing Guidelines\n\n### Code Quality Standards\n\n- **Locators**: Prioritize user-facing, role-based locators (`GetByRole`, `GetByLabel`, `GetByText`, etc.) for resilience and accessibility. Use `await Test.StepAsync()` to group interactions and improve test readability and reporting.\n- **Assertions**: Use auto-retrying web-first assertions. These assertions use `Expect()` from Playwright assertions (e.g., `await Expect(locator).ToHaveTextAsync()`). Avoid checking visibility unless specifically testing for visibility changes.\n- **Timeouts**: Rely on Playwright's built-in auto-waiting mechanisms. Avoid hard-coded waits or increased default timeouts.\n- **Clarity**: Use descriptive test and step titles that clearly state the intent. Add comments only to explain complex logic or non-obvious interactions.\n\n### Test Structure\n\n- **Usings**: Start with `using Microsoft.Playwright;` and either `using Microsoft.Playwright.Xunit;` or `using Microsoft.Playwright.NUnit;` or `using Microsoft.Playwright.MSTest;` for MSTest.\n- **Organization**: Create test classes that inherit from `PageTest` (available in NUnit, xUnit, and MSTest packages) or use `IClassFixture\u003cPlaywrightFixture\u003e` for xUnit with custom fixtures. Group related tests for a feature in the same test class.\n- **Setup**: Use `[SetUp]` (NUnit), `[TestInitialize]` (MSTest), or constructor initialization (xUnit) for setup actions common to all tests (e.g., navigating to a page).\n- **Titles**: Use the appropriate test attribute (`[Test]` for NUnit, `[Fact]` for xUnit, `[TestMethod]` for MSTest) with descriptive method names following C# naming conventions (e.g., `SearchForMovieByTitle`).\n\n### File Organization\n\n- **Location**: Store all test files in a `Tests/` directory or organize by feature.\n- **Naming**: Use the convention `\u003cFeatureOrPage\u003eTests.cs` (e.g., `LoginTests.cs`, `SearchTests.cs`).\n- **Scope**: Aim for one test class per major application feature or page.\n\n### Assertion Best Practices\n\n- **UI Structure**: Use `ToMatchAriaSnapshotAsync` to verify the accessibility tree structure of a component. This provides a comprehensive and accessible snapshot.\n- **Element Counts**: Use `ToHaveCountAsync` to assert the number of elements found by a locator.\n- **Text Content**: Use `ToHaveTextAsync` for exact text matches and `ToContainTextAsync` for partial matches.\n- **Navigation**: Use `ToHaveURLAsync` to verify the page URL after an action.\n\n## Example Test Structure\n\n```csharp\nusing Microsoft.Playwright;\nusing Microsoft.Playwright.Xunit;\nusing static Microsoft.Playwright.Assertions;\n\nnamespace PlaywrightTests;\n\npublic class MovieSearchTests : PageTest\n{\n    public override async Task InitializeAsync()\n    {\n        await base.InitializeAsync();\n        // Navigate to the application before each test\n        await Page.GotoAsync(\"https://debs-obrien.github.io/playwright-movies-app\");\n    }\n\n    [Fact]\n    public async Task SearchForMovieByTitle()\n    {\n        await Test.StepAsync(\"Activate and perform search\", async () =\u003e\n        {\n            await Page.GetByRole(AriaRole.Search).ClickAsync();\n            var searchInput = Page.GetByRole(AriaRole.Textbox, new() { Name = \"Search Input\" });\n            await searchInput.FillAsync(\"Garfield\");\n            await searchInput.PressAsync(\"Enter\");\n        });\n\n        await Test.StepAsync(\"Verify search results\", async () =\u003e\n        {\n            // Verify the accessibility tree of the search results\n            await Expect(Page.GetByRole(AriaRole.Main)).ToMatchAriaSnapshotAsync(@\"\n                - main:\n                  - heading \"\"Garfield\"\" [level=1]\n                  - heading \"\"search results\"\" [level=2]\n                  - list \"\"movies\"\":\n                    - listitem \"\"movie\"\":\n                      - link \"\"poster of The Garfield Movie The Garfield Movie rating\"\":\n                        - /url: /playwright-movies-app/movie?id=tt5779228\u0026page=1\n                        - img \"\"poster of The Garfield Movie\"\"\n                        - heading \"\"The Garfield Movie\"\" [level=2]\n            \");\n        });\n    }\n}\n```\n\n## Test Execution Strategy\n\n1. **Initial Run**: Execute tests with `dotnet test` or using the test runner in your IDE\n2. **Debug Failures**: Analyze test failures and identify root causes\n3. **Iterate**: Refine locators, assertions, or test logic as needed\n4. **Validate**: Ensure tests pass consistently and cover the intended functionality\n5. **Report**: Provide feedback on test results and any issues discovered\n\n## Quality Checklist\n\nBefore finalizing tests, ensure:\n\n- [ ] All locators are accessible and specific and avoid strict mode violations\n- [ ] Tests are grouped logically and follow a clear structure\n- [ ] Assertions are meaningful and reflect user expectations\n- [ ] Tests follow consistent naming conventions\n- [ ] Code is properly formatted and commented\n","description":"Playwright .NET test generation instructions","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-dotnet.instructions.md"},"manifest":{}},"content_hash":[108,81,251,112,126,131,68,203,226,214,30,84,219,73,70,174,141,179,233,107,83,88,152,234,6,216,36,144,33,118,76,70],"trust_level":"unsigned","yanked":false}
