Playwright E2E testing with Page Object pattern, web-first assertions, and proper locators. Triggers on playwright, e2e, page object, getByRole.
Write reliable E2E tests using Playwright with Page Object pattern and web-first assertions. Triggers on playwright, e2e, page object, or getByRole keywords.
/plugin marketplace add settlemint/agent-marketplace/plugin install devtools@settlemintThis skill inherits all available tools. When active, it can use any tool Claude has access to.
<mcp_first> CRITICAL: Always fetch Playwright documentation for current API.
MCPSearch({ query: "select:mcp__plugin_devtools_context7__query-docs" })
// Locator patterns
mcp__context7__query_docs({
libraryId: "/microsoft/playwright",
query: "How do I use getByRole, getByLabel, getByTestId, and locator?",
});
// Assertions
mcp__context7__query_docs({
libraryId: "/microsoft/playwright",
query: "How do I use expect with toBeVisible, toHaveText, and toContainText?",
});
// Page interactions
mcp__context7__query_docs({
libraryId: "/microsoft/playwright",
query: "How do I use click, fill, check, and waitFor?",
});
Note: Context7 v2 uses server-side filtering. Use descriptive natural language queries. </mcp_first>
<quick_start> Page Object pattern:
// pages/login.page.ts
class LoginPage extends BasePage {
async login(email: string, password: string) {
await this.page.getByLabel("Email").fill(email);
await this.page.getByLabel("Password").fill(password);
await this.page.getByRole("button", { name: "Sign in" }).click();
}
async verifyLoggedIn() {
await expect(
this.page.getByRole("heading", { name: "Dashboard" }),
).toBeVisible();
}
}
Test structure:
import { test, expect } from "@playwright/test";
import { Pages } from "../pages/pages";
test.describe.serial("Login flow", () => {
let pages: ReturnType<typeof Pages>;
test.beforeEach(async ({ page }) => {
pages = Pages(page);
});
test("should login successfully", async () => {
await pages.loginPage.goto();
await pages.loginPage.login("user@example.com", "password");
await pages.loginPage.verifyLoggedIn();
});
});
</quick_start>
<locator_priority> Use locators in this order (most to least preferred):
getByRole() - Accessible namegetByLabel() - Form labelsgetByText() - Visible textgetByTestId() - Test IDs// ✅ Preferred
page.getByRole("button", { name: "Submit" });
page.getByLabel("Email");
page.getByText("Welcome");
// ⚠️ Use when needed
page.getByTestId("submit-button");
// ❌ Avoid
page.locator(".btn-primary");
page.locator("#submit");
</locator_priority>
<assertions> **Web-first assertions (auto-wait):**await expect(locator).toBeVisible();
await expect(locator).toHaveText("expected");
await expect(locator).toContainText("partial");
await expect(locator).toHaveValue("value");
await expect(locator).toBeEnabled();
await expect(locator).toBeChecked();
await expect(page).toHaveURL(/pattern/);
await expect(page).toHaveTitle("Title");
</assertions>
<constraints>
**Banned:** Selectors in test files (use page objects), `isVisible()`, CSS class selectors, `page.waitForTimeout()`, `.only`/`.skip` in commits
Required:
BasePagetest.describe.serial() for related testsLocator Priority: getByRole() → getByLabel() → getByText() → getByTestId() → CSS
</constraints>
<success_criteria>
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.