Playwright tester

From I-Synergy/I-Synergy.Framework · View interactive version

Playwright tester is an AI agent skill from the GitHub repository I-Synergy/I-Synergy.Framework. Playwright E2E and UI testing specialist. Use for implementing UI tests, E2E workflows, accessibility testing, or visual regression testing.

How to use this skill

Skill file

Playwright Tester Skill

Specialized agent for Playwright UI testing (Blazor/MAUI apps).

Expertise Areas

Responsibilities

  1. E2E Test Creation
  1. Cross-Browser Testing
  1. Accessibility Testing
  1. Visual Testing

Playwright Test Pattern

using Microsoft.Playwright;
using Microsoft.Playwright.MSTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace {ApplicationName}.UI.Tests;

[TestClass]
public class {Entity}PageTests : PageTest
{
    [TestMethod]
    public async Task CreateButton_Click_OpensCreateDialog()
    {
        // Arrange
        await Page.GotoAsync("https://localhost:5001/{entities}");

        // Act
        await Page.ClickAsync("button:has-text('Create')");

        // Assert
        await Expect(Page.Locator(".dialog-create-{entity}")).ToBeVisibleAsync();
    }

    [TestMethod]
    public async Task CreateForm_ValidData_Creates{Entity}Successfully()
    {
        // Arrange
        await Page.GotoAsync("https://localhost:5001/{entities}/create");

        // Act
        await Page.FillAsync("#property1", "Test Value");
        await Page.FillAsync("#property2", "100.50");
        await Page.ClickAsync("button[type='submit']");

        // Assert
        await Expect(Page.Locator(".success-message")).ToBeVisibleAsync();
        await Expect(Page).ToHaveURLAsync(new Regex(@"/{entities}/\w+"));
    }
}

Locator Strategies

// Prefer text locators
await Page.ClickAsync("button:has-text('Submit')");

// Use test IDs for stability
await Page.ClickAsync("[data-testid='submit-button']");

// CSS selectors
await Page.FillAsync("#input-name", "value");

// ARIA roles
await Page.ClickAsync("role=button[name='Submit']");

Waiting Strategies

// Wait for element to be visible
await Page.WaitForSelectorAsync(".element", new() { State = WaitForSelectorState.Visible });

// Wait for navigation
await Page.RunAndWaitForNavigationAsync(async () =>
{
    await Page.ClickAsync("a[href='/page']");
});

// Wait for API response
await Page.RunAndWaitForResponseAsync(
    response => response.Url.Contains("/api/{entities}") && response.Status == 200,
    async () => await Page.ClickAsync("button[type='submit']"));

Accessibility Testing

[TestMethod]
public async Task {Entity}Form_AccessibilityCheck_PassesAudit()
{
    await Page.GotoAsync("https://localhost:5001/{entities}/create");

    // Check for ARIA labels
    var inputs = await Page.Locator("input").AllAsync();
    foreach (var input in inputs)
    {
        var ariaLabel = await input.GetAttributeAsync("aria-label");
        var labelFor = await input.GetAttributeAsync("id");

        Assert.IsTrue(
            !string.IsNullOrEmpty(ariaLabel) || !string.IsNullOrEmpty(labelFor),
            "Input must have aria-label or associated label");
    }
}

Visual Regression Testing

[TestMethod]
public async Task {Entity}Page_Screenshot_MatchesBaseline()
{
    await Page.GotoAsync("https://localhost:5001/{entities}");

    await Expect(Page).ToHaveScreenshotAsync("{entity}-page.png");
}

Test Organization

tests/
  {ApplicationName}.UI.Tests/
    Pages/
      {Entity}PageTests.cs
    Components/
      {Entity}FormTests.cs
    Workflows/
      {Entity}ManagementWorkflowTests.cs

Test Documentation

The E2E surface produces the same 29119-3 items as the unit surface, right-sized in

.ai/reference/test-documentation.md. Four consequences:

.ai/reference/templates/test-plan.md.txt) names which criteria are only observable through the

UI, marks them at the E2E level, and carries the browser and viewport matrix in its environment

section. Add rows to that plan — do not write a second plan for the UI.

the trace vehicle is [TestCategory("AC-…")] on the method, matching

.ai/reference/traceability.md. The mapping is the document.

Playwright trace, screenshot or video and reference its path from

.ai/reference/templates/test-incident-report.md.txt. A report without the artifact is not

reproducible.

workflow.

Checklist Before Completion

(.ai/reference/traceability.md)

(docs/slices/{Domain}/{Entity}.{Operation}/test-plan.md)

expected vs actual results, a severity from .ai/reference/quality-model.md, and a status

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.