1
---
2
name: webapp-testing
3
description: Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
4
---
5
6
# Web Application Testing
7
8
This skill enables comprehensive testing and debugging of local web applications using Playwright automation.
9
10
You should use the Playwright MCP Server to undertake the work if possible. If the MCP Server is unavailable, you can run the code in a local Node.js environment with Playwright installed.
11
12
## When to Use This Skill
13
14
Use this skill when you need to:
15
16
- Test frontend functionality in a real browser
17
- Verify UI behavior and interactions
18
- Debug web application issues
19
- Capture screenshots for documentation or debugging
20
- Inspect browser console logs
21
- Validate form submissions and user flows
22
- Check responsive design across viewports
23
24
## Prerequisites
25
26
- Node.js installed on the system
27
- A locally running web application (or accessible URL)
28
- Playwright will be installed automatically if not present
29
30
## Core Capabilities
31
32
### 1. Browser Automation
33
34
- Navigate to URLs
35
- Click buttons and links
36
- Fill form fields
37
- Select dropdowns
38
- Handle dialogs and alerts
39
40
### 2. Verification
41
42
- Assert element presence
43
- Verify text content
44
- Check element visibility
45
- Validate URLs
46
- Test responsive behavior
47
48
### 3. Debugging
49
50
- Capture screenshots
51
- View console logs
52
- Inspect network requests
53
- Debug failed tests
54
55
## Usage Examples
56
57
### Example 1: Basic Navigation Test
58
59
```javascript
60
// Navigate to a page and verify title
61
await page.goto("http://localhost:3000");
62
const title = await page.title();
63
console.log("Page title:", title);
64
```
65
66
### Example 2: Form Interaction
67
68
```javascript
69
// Fill out and submit a form
70
await page.fill("#username", "testuser");
71
await page.fill("#password", "password123");
72
await page.click('button[type="submit"]');
73
await page.waitForURL("**/dashboard");
74
```
75
76
### Example 3: Screenshot Capture
77
78
```javascript
79
// Capture a screenshot for debugging
80
await page.screenshot({ path: "debug.png", fullPage: true });
81
```
82
83
## Guidelines
84
85
1. **Always verify the app is running** - Check that the local server is accessible before running tests
86
2. **Use explicit waits** - Wait for elements or navigation to complete before interacting
87
3. **Capture screenshots on failure** - Take screenshots to help debug issues
88
4. **Clean up resources** - Always close the browser when done
89
5. **Handle timeouts gracefully** - Set reasonable timeouts for slow operations
90
6. **Test incrementally** - Start with simple interactions before complex flows
91
7. **Use selectors wisely** - Prefer data-testid or role-based selectors over CSS classes
92
93
## Common Patterns
94
95
### Pattern: Wait for Element
96
97
```javascript
98
await page.waitForSelector("#element-id", { state: "visible" });
99
```
100
101
### Pattern: Check if Element Exists
102
103
```javascript
104
const exists = (await page.locator("#element-id").count()) > 0;
105
```
106
107
### Pattern: Get Console Logs
108
109
```javascript
110
page.on("console", (msg) => console.log("Browser log:", msg.text()));
111
```
112
113
### Pattern: Handle Errors
114
115
```javascript
116
try {
117
await page.click("#button");
118
} catch (error) {
119
await page.screenshot({ path: "error.png" });
120
throw error;
121
}
122
```
123
124
## Limitations
125
126
- Requires Node.js environment
127
- Cannot test native mobile apps (use React Native Testing Library instead)
128
- May have issues with complex authentication flows
129
- Some modern frameworks may require specific configuration
130
131
## Helper Functions
132
133
Some helper functions are available in [`test-helper.js`](./assets/test-helper.js) to simplify common tasks like waiting for elements, capturing screenshots, and handling errors. You can import and use these functions in your tests to improve readability and maintainability.
134