Skip to content

Commit ed9524d

Browse files
suharvestclaude
andcommitted
feat: auto-detect Ollama models from local or remote service
- Add /api/ollama/models endpoint to proxy Ollama /api/tags - Fetch models when URL changes or backend switches to Ollama - Fallback to default list if Ollama API unavailable - Works with both local and remote Ollama services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 77ffc13 commit ed9524d

39 files changed

Lines changed: 1811 additions & 0 deletions
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
---
2+
name: playwright-cli
3+
description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
4+
allowed-tools: Bash(playwright-cli:*)
5+
---
6+
7+
# Browser Automation with playwright-cli
8+
9+
## Quick start
10+
11+
```bash
12+
playwright-cli open https://playwright.dev
13+
playwright-cli click e15
14+
playwright-cli type "page.click"
15+
playwright-cli press Enter
16+
```
17+
18+
## Core workflow
19+
20+
1. Navigate: `playwright-cli open https://example.com`
21+
2. Interact using refs from the snapshot
22+
3. Re-snapshot after significant changes
23+
24+
## Commands
25+
26+
### Core
27+
28+
```bash
29+
playwright-cli open https://example.com/
30+
playwright-cli close
31+
playwright-cli type "search query"
32+
playwright-cli click e3
33+
playwright-cli dblclick e7
34+
playwright-cli fill e5 "user@example.com"
35+
playwright-cli drag e2 e8
36+
playwright-cli hover e4
37+
playwright-cli select e9 "option-value"
38+
playwright-cli upload ./document.pdf
39+
playwright-cli check e12
40+
playwright-cli uncheck e12
41+
playwright-cli snapshot
42+
playwright-cli snapshot --filename=after-click.yaml
43+
playwright-cli eval "document.title"
44+
playwright-cli eval "el => el.textContent" e5
45+
playwright-cli dialog-accept
46+
playwright-cli dialog-accept "confirmation text"
47+
playwright-cli dialog-dismiss
48+
playwright-cli resize 1920 1080
49+
```
50+
51+
### Navigation
52+
53+
```bash
54+
playwright-cli go-back
55+
playwright-cli go-forward
56+
playwright-cli reload
57+
```
58+
59+
### Keyboard
60+
61+
```bash
62+
playwright-cli press Enter
63+
playwright-cli press ArrowDown
64+
playwright-cli keydown Shift
65+
playwright-cli keyup Shift
66+
```
67+
68+
### Mouse
69+
70+
```bash
71+
playwright-cli mousemove 150 300
72+
playwright-cli mousedown
73+
playwright-cli mousedown right
74+
playwright-cli mouseup
75+
playwright-cli mouseup right
76+
playwright-cli mousewheel 0 100
77+
```
78+
79+
### Save as
80+
81+
```bash
82+
playwright-cli screenshot
83+
playwright-cli screenshot e5
84+
playwright-cli screenshot --filename=page.png
85+
playwright-cli pdf --filename=page.pdf
86+
```
87+
88+
### Tabs
89+
90+
```bash
91+
playwright-cli tab-list
92+
playwright-cli tab-new
93+
playwright-cli tab-new https://example.com/page
94+
playwright-cli tab-close
95+
playwright-cli tab-close 2
96+
playwright-cli tab-select 0
97+
```
98+
99+
### Storage
100+
101+
```bash
102+
playwright-cli state-save
103+
playwright-cli state-save auth.json
104+
playwright-cli state-load auth.json
105+
106+
# Cookies
107+
playwright-cli cookie-list
108+
playwright-cli cookie-list --domain=example.com
109+
playwright-cli cookie-get session_id
110+
playwright-cli cookie-set session_id abc123
111+
playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
112+
playwright-cli cookie-delete session_id
113+
playwright-cli cookie-clear
114+
115+
# LocalStorage
116+
playwright-cli localstorage-list
117+
playwright-cli localstorage-get theme
118+
playwright-cli localstorage-set theme dark
119+
playwright-cli localstorage-delete theme
120+
playwright-cli localstorage-clear
121+
122+
# SessionStorage
123+
playwright-cli sessionstorage-list
124+
playwright-cli sessionstorage-get step
125+
playwright-cli sessionstorage-set step 3
126+
playwright-cli sessionstorage-delete step
127+
playwright-cli sessionstorage-clear
128+
```
129+
130+
### Network
131+
132+
```bash
133+
playwright-cli route "**/*.jpg" --status=404
134+
playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
135+
playwright-cli route-list
136+
playwright-cli unroute "**/*.jpg"
137+
playwright-cli unroute
138+
```
139+
140+
### DevTools
141+
142+
```bash
143+
playwright-cli console
144+
playwright-cli console warning
145+
playwright-cli network
146+
playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
147+
playwright-cli tracing-start
148+
playwright-cli tracing-stop
149+
playwright-cli video-start
150+
playwright-cli video-stop video.webm
151+
```
152+
153+
### Install
154+
155+
```bash
156+
playwright-cli install-browser
157+
playwright-cli install-skills
158+
```
159+
160+
### Configuration
161+
```bash
162+
# Use specific browser when creating session
163+
playwright-cli open --browser=chrome
164+
playwright-cli open --browser=firefox
165+
playwright-cli open --browser=webkit
166+
playwright-cli open --browser=msedge
167+
# Connect to browser via extension
168+
playwright-cli open --extension
169+
170+
# Use persistent profile (by default profile is in-memory)
171+
playwright-cli open --persistent
172+
# Use persistent profile with custom directory
173+
playwright-cli open --profile=/path/to/profile
174+
175+
# Start with config file
176+
playwright-cli open --config=my-config.json
177+
178+
# Close the browser
179+
playwright-cli close
180+
# Delete user data for the default session
181+
playwright-cli delete-data
182+
```
183+
184+
### Browser Sessions
185+
186+
```bash
187+
playwright-cli -s=mysession open example.com
188+
playwright-cli -s=mysession click e6
189+
playwright-cli -s=mysession close # stop a named browser
190+
playwright-cli -s=mysession delete-data # delete user data for named browser
191+
192+
playwright-cli list
193+
# Close all browsers
194+
playwright-cli close-all
195+
# Forcefully kill all browser processes
196+
playwright-cli kill-all
197+
```
198+
199+
## Example: Form submission
200+
201+
```bash
202+
playwright-cli open https://example.com/form
203+
playwright-cli snapshot
204+
205+
playwright-cli fill e1 "user@example.com"
206+
playwright-cli fill e2 "password123"
207+
playwright-cli click e3
208+
playwright-cli snapshot
209+
```
210+
211+
## Example: Multi-tab workflow
212+
213+
```bash
214+
playwright-cli open https://example.com
215+
playwright-cli tab-new https://example.com/other
216+
playwright-cli tab-list
217+
playwright-cli tab-select 0
218+
playwright-cli snapshot
219+
```
220+
221+
## Example: Debugging with DevTools
222+
223+
```bash
224+
playwright-cli open https://example.com
225+
playwright-cli click e4
226+
playwright-cli fill e7 "test"
227+
playwright-cli console
228+
playwright-cli network
229+
```
230+
231+
```bash
232+
playwright-cli open https://example.com
233+
playwright-cli tracing-start
234+
playwright-cli click e4
235+
playwright-cli fill e7 "test"
236+
playwright-cli tracing-stop
237+
```
238+
239+
## Specific tasks
240+
241+
* **Request mocking** [references/request-mocking.md](references/request-mocking.md)
242+
* **Running Playwright code** [references/running-code.md](references/running-code.md)
243+
* **Browser session management** [references/session-management.md](references/session-management.md)
244+
* **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
245+
* **Test generation** [references/test-generation.md](references/test-generation.md)
246+
* **Tracing** [references/tracing.md](references/tracing.md)
247+
* **Video recording** [references/video-recording.md](references/video-recording.md)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Request Mocking
2+
3+
Intercept, mock, modify, and block network requests.
4+
5+
## CLI Route Commands
6+
7+
```bash
8+
# Mock with custom status
9+
playwright-cli route "**/*.jpg" --status=404
10+
11+
# Mock with JSON body
12+
playwright-cli route "**/api/users" --body='[{"id":1,"name":"Alice"}]' --content-type=application/json
13+
14+
# Mock with custom headers
15+
playwright-cli route "**/api/data" --body='{"ok":true}' --header="X-Custom: value"
16+
17+
# Remove headers from requests
18+
playwright-cli route "**/*" --remove-header=cookie,authorization
19+
20+
# List active routes
21+
playwright-cli route-list
22+
23+
# Remove a route or all routes
24+
playwright-cli unroute "**/*.jpg"
25+
playwright-cli unroute
26+
```
27+
28+
## URL Patterns
29+
30+
```
31+
**/api/users - Exact path match
32+
**/api/*/details - Wildcard in path
33+
**/*.{png,jpg,jpeg} - Match file extensions
34+
**/search?q=* - Match query parameters
35+
```
36+
37+
## Advanced Mocking with run-code
38+
39+
For conditional responses, request body inspection, response modification, or delays:
40+
41+
### Conditional Response Based on Request
42+
43+
```bash
44+
playwright-cli run-code "async page => {
45+
await page.route('**/api/login', route => {
46+
const body = route.request().postDataJSON();
47+
if (body.username === 'admin') {
48+
route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
49+
} else {
50+
route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
51+
}
52+
});
53+
}"
54+
```
55+
56+
### Modify Real Response
57+
58+
```bash
59+
playwright-cli run-code "async page => {
60+
await page.route('**/api/user', async route => {
61+
const response = await route.fetch();
62+
const json = await response.json();
63+
json.isPremium = true;
64+
await route.fulfill({ response, json });
65+
});
66+
}"
67+
```
68+
69+
### Simulate Network Failures
70+
71+
```bash
72+
playwright-cli run-code "async page => {
73+
await page.route('**/api/offline', route => route.abort('internetdisconnected'));
74+
}"
75+
# Options: connectionrefused, timedout, connectionreset, internetdisconnected
76+
```
77+
78+
### Delayed Response
79+
80+
```bash
81+
playwright-cli run-code "async page => {
82+
await page.route('**/api/slow', async route => {
83+
await new Promise(r => setTimeout(r, 3000));
84+
route.fulfill({ body: JSON.stringify({ data: 'loaded' }) });
85+
});
86+
}"
87+
```

0 commit comments

Comments
 (0)