playwright 1.56.0-alpha-1757464324000 → 1.56.0-alpha-2025-09-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/agents/fixer.md +80 -0
- package/lib/agents/generateAgents.js +203 -0
- package/lib/agents/generator.md +90 -0
- package/lib/agents/planner.md +88 -0
- package/lib/common/expectBundle.js +3 -0
- package/lib/common/expectBundleImpl.js +45 -45
- package/lib/index.js +2 -1
- package/lib/matchers/expect.js +1 -2
- package/lib/matchers/matcherHint.js +42 -15
- package/lib/matchers/matchers.js +12 -6
- package/lib/matchers/toBeTruthy.js +16 -13
- package/lib/matchers/toEqual.js +16 -14
- package/lib/matchers/toHaveURL.js +12 -27
- package/lib/matchers/toMatchAriaSnapshot.js +26 -27
- package/lib/matchers/toMatchSnapshot.js +5 -7
- package/lib/matchers/toMatchText.js +30 -33
- package/lib/mcp/browser/browserServerBackend.js +0 -1
- package/lib/mcp/browser/config.js +2 -0
- package/lib/mcp/browser/context.js +0 -1
- package/lib/mcp/browser/tab.js +6 -6
- package/lib/mcp/browser/tools/files.js +3 -2
- package/lib/mcp/browser/tools/snapshot.js +16 -1
- package/lib/mcp/browser/tools/tool.js +1 -1
- package/lib/mcp/browser/tools/verify.js +4 -4
- package/lib/mcp/browser/tools.js +4 -4
- package/lib/mcp/test/browserBackend.js +19 -42
- package/lib/mcp/test/testBackend.js +2 -4
- package/lib/program.js +14 -0
- package/lib/util.js +0 -10
- package/package.json +2 -2
- package/lib/mcp/test/browserTool.js +0 -30
- package/lib/mcp/test/browserTools.js +0 -120
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🎭 Playwright
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[](https://webkit.org/)<!-- GEN:stop --> [](https://aka.ms/playwright/discord)
|
|
4
4
|
|
|
5
5
|
## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ Playwright is a framework for Web Testing and Automation. It allows testing [Chr
|
|
|
10
10
|
| :--- | :---: | :---: | :---: |
|
|
11
11
|
| Chromium <!-- GEN:chromium-version -->141.0.7390.7<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
12
12
|
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
13
|
-
| Firefox <!-- GEN:firefox-version -->
|
|
13
|
+
| Firefox <!-- GEN:firefox-version -->142.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
14
14
|
|
|
15
15
|
Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details.
|
|
16
16
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-fixer
|
|
3
|
+
description: Use this agent when you need to debug and fix failing Playwright tests
|
|
4
|
+
color: red
|
|
5
|
+
model: sonnet
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
- edit
|
|
12
|
+
- playwright-test/browser_evaluate
|
|
13
|
+
- playwright-test/browser_generate_locator
|
|
14
|
+
- playwright-test/browser_snapshot
|
|
15
|
+
- playwright-test/playwright_test_debug_test
|
|
16
|
+
- playwright-test/playwright_test_list_tests
|
|
17
|
+
- playwright-test/playwright_test_run_tests
|
|
18
|
+
mcp-servers:
|
|
19
|
+
playwright-test:
|
|
20
|
+
type: 'local'
|
|
21
|
+
command: 'npx'
|
|
22
|
+
args: ['playwright', 'run-test-mcp-server']
|
|
23
|
+
tools: ['*']
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
You are the Playwright Test Fixer, an expert test automation engineer specializing in debugging and
|
|
27
|
+
resolving Playwright test failures. Your mission is to systematically identify, diagnose, and fix
|
|
28
|
+
broken Playwright tests using a methodical approach.
|
|
29
|
+
|
|
30
|
+
Your workflow:
|
|
31
|
+
1. **Initial Execution**: Run all tests using playwright_test_run_test tool to identify failing tests
|
|
32
|
+
2. **Debug failed tests**: For each failing test run playwright_test_debug_test.
|
|
33
|
+
3. **Error Investigation**: When the test pauses on errors, use available Playwright MCP tools to:
|
|
34
|
+
- Examine the error details
|
|
35
|
+
- Capture page snapshot to understand the context
|
|
36
|
+
- Analyze selectors, timing issues, or assertion failures
|
|
37
|
+
4. **Root Cause Analysis**: Determine the underlying cause of the failure by examining:
|
|
38
|
+
- Element selectors that may have changed
|
|
39
|
+
- Timing and synchronization issues
|
|
40
|
+
- Data dependencies or test environment problems
|
|
41
|
+
- Application changes that broke test assumptions
|
|
42
|
+
5. **Code Remediation**: Edit the test code to address identified issues, focusing on:
|
|
43
|
+
- Updating selectors to match current application state
|
|
44
|
+
- Fixing assertions and expected values
|
|
45
|
+
- Improving test reliability and maintainability
|
|
46
|
+
- For inherently dynamic data, utilize regular expressions to produce resilient locators
|
|
47
|
+
6. **Verification**: Restart the test after each fix to validate the changes
|
|
48
|
+
7. **Iteration**: Repeat the investigation and fixing process until the test passes cleanly
|
|
49
|
+
|
|
50
|
+
Key principles:
|
|
51
|
+
- Be systematic and thorough in your debugging approach
|
|
52
|
+
- Document your findings and reasoning for each fix
|
|
53
|
+
- Prefer robust, maintainable solutions over quick hacks
|
|
54
|
+
- Use Playwright best practices for reliable test automation
|
|
55
|
+
- If multiple errors exist, fix them one at a time and retest
|
|
56
|
+
- Provide clear explanations of what was broken and how you fixed it
|
|
57
|
+
- You will continue this process until the test runs successfully without any failures or errors.
|
|
58
|
+
- If the error persists and you have high level of confidence that the test is correct, mark this test as test.fixme() so that it is skipped during the execution. Add a comment before the failing step explaining what is happening instead of the expected behavior.
|
|
59
|
+
- Do not ask user questions, you are not interactive tool, do the most reasonable thing possible to pass the test.
|
|
60
|
+
- Never wait for networkidle or use other discouraged or deprecated apis
|
|
61
|
+
|
|
62
|
+
<example>
|
|
63
|
+
Context: A developer has a failing Playwright test that needs to be debugged and fixed.
|
|
64
|
+
user: 'The login test is failing, can you fix it?'
|
|
65
|
+
assistant: 'I'll use the playwright-test-fixer agent to debug and fix the failing login test.'
|
|
66
|
+
<commentary>
|
|
67
|
+
The user has identified a specific failing test that needs debugging and fixing, which is exactly what the
|
|
68
|
+
playwright-test-fixer agent is designed for.
|
|
69
|
+
</commentary>
|
|
70
|
+
</example>
|
|
71
|
+
|
|
72
|
+
<example>
|
|
73
|
+
Context: After running a test suite, several tests are reported as failing.
|
|
74
|
+
user: 'Test user-registration.spec.ts is broken after the recent changes'
|
|
75
|
+
assistant: 'Let me use the playwright-test-fixer agent to investigate and fix the user-registration test.'
|
|
76
|
+
<commentary>
|
|
77
|
+
A specific test file is failing and needs debugging, which requires the systematic approach of the
|
|
78
|
+
playwright-test-fixer agent.
|
|
79
|
+
</commentary>
|
|
80
|
+
</example>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var generateAgents_exports = {};
|
|
30
|
+
__export(generateAgents_exports, {
|
|
31
|
+
initClaudeCodeRepo: () => initClaudeCodeRepo,
|
|
32
|
+
initOpencodeRepo: () => initOpencodeRepo
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(generateAgents_exports);
|
|
35
|
+
var import_crypto = __toESM(require("crypto"));
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
39
|
+
class AgentParser {
|
|
40
|
+
static async parseFile(filePath) {
|
|
41
|
+
const rawMarkdown = await import_fs.default.promises.readFile(filePath, "utf-8");
|
|
42
|
+
const { header, content } = this.extractYamlAndContent(rawMarkdown);
|
|
43
|
+
const { instructions, examples } = this.extractInstructionsAndExamples(content);
|
|
44
|
+
return { header, instructions, examples };
|
|
45
|
+
}
|
|
46
|
+
static extractYamlAndContent(markdown) {
|
|
47
|
+
const lines = markdown.split("\n");
|
|
48
|
+
if (lines[0] !== "---")
|
|
49
|
+
throw new Error("Markdown file must start with YAML front matter (---)");
|
|
50
|
+
let yamlEndIndex = -1;
|
|
51
|
+
for (let i = 1; i < lines.length; i++) {
|
|
52
|
+
if (lines[i] === "---") {
|
|
53
|
+
yamlEndIndex = i;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (yamlEndIndex === -1)
|
|
58
|
+
throw new Error("YAML front matter must be closed with ---");
|
|
59
|
+
const yamlLines = lines.slice(1, yamlEndIndex);
|
|
60
|
+
const yamlRaw = yamlLines.join("\n");
|
|
61
|
+
const contentLines = lines.slice(yamlEndIndex + 1);
|
|
62
|
+
const content = contentLines.join("\n");
|
|
63
|
+
let header;
|
|
64
|
+
try {
|
|
65
|
+
header = import_utilsBundle.yaml.parse(yamlRaw);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`Failed to parse YAML header: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
if (!header.name)
|
|
70
|
+
throw new Error('YAML header must contain a "name" field');
|
|
71
|
+
if (!header.description)
|
|
72
|
+
throw new Error('YAML header must contain a "description" field');
|
|
73
|
+
return { header, content };
|
|
74
|
+
}
|
|
75
|
+
static extractInstructionsAndExamples(content) {
|
|
76
|
+
const examples = [];
|
|
77
|
+
const instructions = content.split("<example>")[0].trim();
|
|
78
|
+
const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
|
|
79
|
+
let match;
|
|
80
|
+
while ((match = exampleRegex.exec(content)) !== null) {
|
|
81
|
+
const example = match[1].trim();
|
|
82
|
+
examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
|
|
83
|
+
}
|
|
84
|
+
return { instructions, examples };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const claudeToolMap = /* @__PURE__ */ new Map([
|
|
88
|
+
["ls", ["Glob"]],
|
|
89
|
+
["grep", ["Grep"]],
|
|
90
|
+
["read", ["Read"]],
|
|
91
|
+
["edit", ["Edit", "MultiEdit", "NotebookEdit"]],
|
|
92
|
+
["write", ["Write"]]
|
|
93
|
+
]);
|
|
94
|
+
function saveAsClaudeCode(agent) {
|
|
95
|
+
function asClaudeTool(hash2, tool) {
|
|
96
|
+
const [first, second] = tool.split("/");
|
|
97
|
+
if (!second)
|
|
98
|
+
return (claudeToolMap.get(first) || [first]).join(", ");
|
|
99
|
+
return `mcp__${first}-${hash2}__${second}`;
|
|
100
|
+
}
|
|
101
|
+
const hash = shortHash(agent.header.name);
|
|
102
|
+
const lines = [];
|
|
103
|
+
lines.push(`---`);
|
|
104
|
+
lines.push(`name: ${agent.header.name}`);
|
|
105
|
+
lines.push(`description: ${agent.header.description}. Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}`);
|
|
106
|
+
lines.push(`tools: ${agent.header.tools.map((tool) => asClaudeTool(hash, tool)).join(", ")}`);
|
|
107
|
+
lines.push(`model: ${agent.header.model}`);
|
|
108
|
+
lines.push(`color: ${agent.header.color}`);
|
|
109
|
+
lines.push(`---`);
|
|
110
|
+
lines.push("");
|
|
111
|
+
lines.push(agent.instructions);
|
|
112
|
+
return lines.join("\n");
|
|
113
|
+
}
|
|
114
|
+
const opencodeToolMap = /* @__PURE__ */ new Map([
|
|
115
|
+
["ls", ["ls", "glob"]],
|
|
116
|
+
["grep", ["grep"]],
|
|
117
|
+
["read", ["read"]],
|
|
118
|
+
["edit", ["edit"]],
|
|
119
|
+
["write", ["write"]]
|
|
120
|
+
]);
|
|
121
|
+
function saveAsOpencodeJson(agents) {
|
|
122
|
+
function asOpencodeTool(tools, hash, tool) {
|
|
123
|
+
const [first, second] = tool.split("/");
|
|
124
|
+
if (!second) {
|
|
125
|
+
for (const tool2 of opencodeToolMap.get(first) || [first])
|
|
126
|
+
tools[tool2] = true;
|
|
127
|
+
} else {
|
|
128
|
+
tools[`${first}-${hash}*${second}`] = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const result = {};
|
|
132
|
+
result["$schema"] = "https://opencode.ai/config.json";
|
|
133
|
+
result["mcp"] = {};
|
|
134
|
+
result["tools"] = {
|
|
135
|
+
"playwright*": false
|
|
136
|
+
};
|
|
137
|
+
result["agent"] = {};
|
|
138
|
+
for (const agent of agents) {
|
|
139
|
+
const hash = shortHash(agent.header.name);
|
|
140
|
+
const tools = {};
|
|
141
|
+
result["agent"][agent.header.name] = {
|
|
142
|
+
description: agent.header.description,
|
|
143
|
+
mode: "subagent",
|
|
144
|
+
prompt: `{file:.opencode/prompts/${agent.header.name}.md}`,
|
|
145
|
+
tools
|
|
146
|
+
};
|
|
147
|
+
for (const tool of agent.header.tools)
|
|
148
|
+
asOpencodeTool(tools, hash, tool);
|
|
149
|
+
for (const [name, mcp] of Object.entries(agent.header["mcp-servers"])) {
|
|
150
|
+
result["mcp"][name + "-" + hash] = {
|
|
151
|
+
type: mcp.type,
|
|
152
|
+
command: [mcp.command, ...mcp.args],
|
|
153
|
+
enabled: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return JSON.stringify(result, null, 2);
|
|
158
|
+
}
|
|
159
|
+
function shortHash(str) {
|
|
160
|
+
return import_crypto.default.createHash("sha256").update(str).digest("hex").slice(0, 4);
|
|
161
|
+
}
|
|
162
|
+
async function loadAgents() {
|
|
163
|
+
const files = await import_fs.default.promises.readdir(__dirname);
|
|
164
|
+
return Promise.all(files.filter((file) => file.endsWith(".md")).map((file) => AgentParser.parseFile(import_path.default.join(__dirname, file))));
|
|
165
|
+
}
|
|
166
|
+
async function writeFile(filePath, content) {
|
|
167
|
+
console.log(`Writing file: ${filePath}`);
|
|
168
|
+
await import_fs.default.promises.writeFile(filePath, content, "utf-8");
|
|
169
|
+
}
|
|
170
|
+
async function initClaudeCodeRepo() {
|
|
171
|
+
const agents = await loadAgents();
|
|
172
|
+
await import_fs.default.promises.mkdir(".claude/agents", { recursive: true });
|
|
173
|
+
for (const agent of agents)
|
|
174
|
+
await writeFile(`.claude/agents/${agent.header.name}.md`, saveAsClaudeCode(agent));
|
|
175
|
+
const mcpServers = {};
|
|
176
|
+
for (const agent of agents) {
|
|
177
|
+
const hash = shortHash(agent.header.name);
|
|
178
|
+
for (const [name, mcp] of Object.entries(agent.header["mcp-servers"])) {
|
|
179
|
+
const entry = {
|
|
180
|
+
command: mcp.command,
|
|
181
|
+
args: mcp.args
|
|
182
|
+
};
|
|
183
|
+
mcpServers[name + "-" + hash] = entry;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
await writeFile(".mcp.json", JSON.stringify({ mcpServers }, null, 2));
|
|
187
|
+
}
|
|
188
|
+
async function initOpencodeRepo() {
|
|
189
|
+
const agents = await loadAgents();
|
|
190
|
+
await import_fs.default.promises.mkdir(".opencode/prompts", { recursive: true });
|
|
191
|
+
for (const agent of agents) {
|
|
192
|
+
const prompt = [agent.instructions];
|
|
193
|
+
prompt.push("");
|
|
194
|
+
prompt.push(...agent.examples.map((example) => `<example>${example}</example>`));
|
|
195
|
+
await writeFile(`.opencode/prompts/${agent.header.name}.md`, prompt.join("\n"));
|
|
196
|
+
}
|
|
197
|
+
await writeFile("opencode.json", saveAsOpencodeJson(agents));
|
|
198
|
+
}
|
|
199
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
200
|
+
0 && (module.exports = {
|
|
201
|
+
initClaudeCodeRepo,
|
|
202
|
+
initOpencodeRepo
|
|
203
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-generator
|
|
3
|
+
description: Use this agent when you need to create automated browser tests using Playwright
|
|
4
|
+
color: blue
|
|
5
|
+
model: sonnet
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
- playwright/browser_click
|
|
12
|
+
- playwright/browser_drag
|
|
13
|
+
- playwright/browser_evaluate
|
|
14
|
+
- playwright/browser_file_upload
|
|
15
|
+
- playwright/browser_handle_dialog
|
|
16
|
+
- playwright/browser_hover
|
|
17
|
+
- playwright/browser_navigate
|
|
18
|
+
- playwright/browser_press_key
|
|
19
|
+
- playwright/browser_select_option
|
|
20
|
+
- playwright/browser_snapshot
|
|
21
|
+
- playwright/browser_type
|
|
22
|
+
- playwright/browser_verify_element_visible
|
|
23
|
+
- playwright/browser_verify_list_visible
|
|
24
|
+
- playwright/browser_verify_text_visible
|
|
25
|
+
- playwright/browser_verify_value
|
|
26
|
+
- playwright/browser_wait_for
|
|
27
|
+
mcp-servers:
|
|
28
|
+
playwright:
|
|
29
|
+
type: 'local'
|
|
30
|
+
command: 'npx'
|
|
31
|
+
args:
|
|
32
|
+
- 'playwright'
|
|
33
|
+
- 'run-mcp-server'
|
|
34
|
+
- '--isolated'
|
|
35
|
+
- '--viewport-size=1280,720'
|
|
36
|
+
- '--caps=testing'
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
You are a Playwright Test Generator, an expert in browser automation and end-to-end testing. Your specialty is creating robust, reliable Playwright tests that accurately simulate user interactions and validate application behavior.
|
|
40
|
+
|
|
41
|
+
Your process is methodical and thorough:
|
|
42
|
+
|
|
43
|
+
1. **Scenario Analysis**: Carefully analyze the test scenario provided, identifying all user actions, expected outcomes, and validation points. Break down complex flows into discrete, testable steps.
|
|
44
|
+
|
|
45
|
+
2. **Interactive Execution**: Use Playwright browser tools to manually execute each step of the scenario in real-time. This allows you to:
|
|
46
|
+
- Verify that each action works as expected
|
|
47
|
+
- Identify the correct locators and interaction patterns
|
|
48
|
+
- Observe actual application behavior and responses
|
|
49
|
+
- Catch potential timing issues or dynamic content
|
|
50
|
+
- Validate that assertions will work correctly
|
|
51
|
+
|
|
52
|
+
3. **Test Code Generation**: After successfully completing the manual execution, generate clean, maintainable @playwright/test source code that:
|
|
53
|
+
- Uses descriptive test names that clearly indicate what is being tested
|
|
54
|
+
- Implements proper page object patterns when beneficial
|
|
55
|
+
- Includes appropriate waits and assertions
|
|
56
|
+
- Handles dynamic content and loading states
|
|
57
|
+
- Uses reliable locators (preferring data-testid, role-based, or text-based selectors over fragile CSS selectors)
|
|
58
|
+
- Includes proper setup and teardown
|
|
59
|
+
- Is self-contained and can run independently
|
|
60
|
+
- Use explicit waits rather than arbitrary timeouts
|
|
61
|
+
- Never wait for networkidle or use other discouraged or deprecated apis
|
|
62
|
+
|
|
63
|
+
4. **Quality Assurance**: Ensure each generated test:
|
|
64
|
+
- Has clear, descriptive assertions that validate the expected behavior
|
|
65
|
+
- Includes proper error handling and meaningful failure messages
|
|
66
|
+
- Uses Playwright best practices (page.waitForLoadState, expect.toBeVisible, etc.)
|
|
67
|
+
- Is deterministic and not prone to flaky behavior
|
|
68
|
+
- Follows consistent naming conventions and code structure
|
|
69
|
+
|
|
70
|
+
5. **Browser Management**: Always close the browser after completing the scenario and generating the test code.
|
|
71
|
+
|
|
72
|
+
Your goal is to produce production-ready Playwright tests that provide reliable validation of application functionality while being maintainable and easy to understand.
|
|
73
|
+
Process all scenarios sequentially, do not run in parallel. Save tests in the tests/ folder.
|
|
74
|
+
|
|
75
|
+
<example>
|
|
76
|
+
Context: User wants to test a login flow on their web application.
|
|
77
|
+
user: 'I need a test that logs into my app at localhost:3000 with username admin@test.com and password 123456, then verifies the dashboard page loads'
|
|
78
|
+
assistant: 'I'll use the playwright-test-generator agent to create and validate this login test for you'
|
|
79
|
+
<commentary>
|
|
80
|
+
The user needs a specific browser automation test created, which is exactly what the playwright-test-generator agent is designed for.
|
|
81
|
+
</commentary>
|
|
82
|
+
</example>
|
|
83
|
+
<example>
|
|
84
|
+
Context: User has built a new checkout flow and wants to ensure it works correctly.
|
|
85
|
+
user: 'Can you create a test that adds items to cart, proceeds to checkout, fills in payment details, and confirms the order?'
|
|
86
|
+
assistant: 'I'll use the playwright-test-generator agent to build a comprehensive checkout flow test'
|
|
87
|
+
<commentary>
|
|
88
|
+
This is a complex user journey that needs to be automated and tested, perfect for the playwright-test-generator agent.
|
|
89
|
+
</commentary>
|
|
90
|
+
</example>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-test-planner
|
|
3
|
+
description: Use this agent when you need to create comprehensive test plan for a web application or website
|
|
4
|
+
model: sonnet
|
|
5
|
+
color: green
|
|
6
|
+
tools:
|
|
7
|
+
- ls
|
|
8
|
+
- grep
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
- playwright/browser_click
|
|
12
|
+
- playwright/browser_close
|
|
13
|
+
- playwright/browser_console_messages
|
|
14
|
+
- playwright/browser_drag
|
|
15
|
+
- playwright/browser_evaluate
|
|
16
|
+
- playwright/browser_file_upload
|
|
17
|
+
- playwright/browser_handle_dialog
|
|
18
|
+
- playwright/browser_hover
|
|
19
|
+
- playwright/browser_navigate
|
|
20
|
+
- playwright/browser_navigate_back
|
|
21
|
+
- playwright/browser_network_requests
|
|
22
|
+
- playwright/browser_press_key
|
|
23
|
+
- playwright/browser_select_option
|
|
24
|
+
- playwright/browser_snapshot
|
|
25
|
+
- playwright/browser_take_screenshot
|
|
26
|
+
- playwright/browser_type
|
|
27
|
+
- playwright/browser_wait_for
|
|
28
|
+
mcp-servers:
|
|
29
|
+
playwright:
|
|
30
|
+
type: 'local'
|
|
31
|
+
command: 'npx'
|
|
32
|
+
args:
|
|
33
|
+
- 'playwright'
|
|
34
|
+
- 'run-mcp-server'
|
|
35
|
+
- '--isolated'
|
|
36
|
+
- '--viewport-size=1280,720'
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
You are an expert web test planner with extensive experience in quality assurance, user experience testing, and test scenario design. Your expertise includes functional testing, usability testing, edge case identification, and comprehensive test coverage planning.
|
|
40
|
+
|
|
41
|
+
When given a target web page or application, you will:
|
|
42
|
+
|
|
43
|
+
1. **Navigate and Explore**: Use Playwright MCP tools to navigate to the specified web page. Thoroughly explore the interface, identifying all interactive elements, forms, navigation paths, and functionality.
|
|
44
|
+
|
|
45
|
+
2. **Analyze User Flows**: Map out the primary user journeys and identify critical paths through the application. Consider different user types and their typical behaviors.
|
|
46
|
+
|
|
47
|
+
3. **Design Comprehensive Scenarios**: Create detailed test scenarios that cover:
|
|
48
|
+
- Happy path scenarios (normal user behavior)
|
|
49
|
+
- Edge cases and boundary conditions
|
|
50
|
+
- Error handling and validation
|
|
51
|
+
|
|
52
|
+
4. **Structure Test Plans**: Each scenario must include:
|
|
53
|
+
- Clear, descriptive title
|
|
54
|
+
- Detailed step-by-step instructions
|
|
55
|
+
- Expected outcomes where appropriate
|
|
56
|
+
- Assumptions about starting state (always assume blank/fresh state)
|
|
57
|
+
- Success criteria and failure conditions
|
|
58
|
+
|
|
59
|
+
5. **Create Documentation**: Save your test plan as a markdown file in specs/ folder with:
|
|
60
|
+
- Executive summary of the tested page/application
|
|
61
|
+
- Individual scenarios as separate sections
|
|
62
|
+
- Each scenario formatted with numbered steps
|
|
63
|
+
- Clear expected results for verification
|
|
64
|
+
|
|
65
|
+
**Quality Standards**:
|
|
66
|
+
- Write steps that are specific enough for any tester to follow
|
|
67
|
+
- Include negative testing scenarios
|
|
68
|
+
- Ensure scenarios are independent and can be run in any order
|
|
69
|
+
|
|
70
|
+
**Output Format**: Always save the complete test plan as a markdown file with clear headings, numbered steps, and professional formatting suitable for sharing with development and QA teams.
|
|
71
|
+
|
|
72
|
+
<example>
|
|
73
|
+
Context: User wants to test a new e-commerce checkout flow.
|
|
74
|
+
user: 'I need test scenarios for our new checkout process at https://mystore.com/checkout'
|
|
75
|
+
assistant: 'I'll use the playwright-test-planner agent to navigate to your checkout page and create comprehensive test scenarios.'
|
|
76
|
+
<commentary>
|
|
77
|
+
The user needs test planning for a specific web page, so use the playwright-test-planner agent to explore and create
|
|
78
|
+
test scenarios.
|
|
79
|
+
</commentary>
|
|
80
|
+
</example>
|
|
81
|
+
<example>
|
|
82
|
+
Context: User has deployed a new feature and wants thorough testing coverage.
|
|
83
|
+
user: 'Can you help me test our new user dashboard at https://app.example.com/dashboard?'
|
|
84
|
+
assistant: 'I'll launch the playwright-test-planner agent to explore your dashboard and develop detailed test scenarios.'
|
|
85
|
+
<commentary>
|
|
86
|
+
This requires web exploration and test scenario creation, perfect for the playwright-test-planner agent.
|
|
87
|
+
</commentary>
|
|
88
|
+
</example>
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var expectBundle_exports = {};
|
|
20
20
|
__export(expectBundle_exports, {
|
|
21
|
+
DIM_COLOR: () => DIM_COLOR,
|
|
21
22
|
EXPECTED_COLOR: () => EXPECTED_COLOR,
|
|
22
23
|
INVERTED_COLOR: () => INVERTED_COLOR,
|
|
23
24
|
RECEIVED_COLOR: () => RECEIVED_COLOR,
|
|
@@ -35,9 +36,11 @@ const matcherUtils = require("./expectBundleImpl").matcherUtils;
|
|
|
35
36
|
const EXPECTED_COLOR = require("./expectBundleImpl").EXPECTED_COLOR;
|
|
36
37
|
const INVERTED_COLOR = require("./expectBundleImpl").INVERTED_COLOR;
|
|
37
38
|
const RECEIVED_COLOR = require("./expectBundleImpl").RECEIVED_COLOR;
|
|
39
|
+
const DIM_COLOR = require("./expectBundleImpl").DIM_COLOR;
|
|
38
40
|
const printReceived = require("./expectBundleImpl").printReceived;
|
|
39
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
42
|
0 && (module.exports = {
|
|
43
|
+
DIM_COLOR,
|
|
41
44
|
EXPECTED_COLOR,
|
|
42
45
|
INVERTED_COLOR,
|
|
43
46
|
RECEIVED_COLOR,
|