Terminal: find field takes the keyboard; docs, capture kit right-click

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 00:52:19 +00:00
parent e65354496a
commit 9ab7f50cce
7 changed files with 101 additions and 3 deletions
+1
View File
@@ -55,6 +55,7 @@ In JSON, a step can also set `wait` (ms), `timeout`, `name`, `ms` and `frames`.
| `type=text` | type into the focused field (or the first visible one) |
| `press=Enter` | press a key: Enter, Escape, Tab, Backspace, ArrowUp, ArrowDown, a letter or a digit, optionally after `Control+`, `Shift+`, `Alt+` or `Meta+` (`press=Control+2`) |
| `scroll=600` | scroll with the mouse wheel at the centre (JSON `at` sets a target, `dx` a horizontal delta, `repeat` and `gap` a run of ticks) |
| `rightclick=<target>` | click the secondary mouse button on the target (context menus), then wait |
| `hover=<target>` | move the mouse onto the target without pressing (hover states) |
| `drag=<target>>dx,dy` | press on the target, move by dx,dy in `steps` (12) moves `gap` (16) ms apart, release (JSON `dx`, `dy`, `steps`, `gap`; `hold: true` keeps the button down to capture mid-drag) |
| `size=WxH` | resize without reloading |
+7
View File
@@ -25,6 +25,7 @@ steps: open=<route>[@WxH] wait=<ms> shot=<name> click=<target> waitfor=<target
type=<text> press=<Enter|Escape|Tab|...> scroll=<dy> size=WxH
files=<path>[,<path>] (answers the next file chooser)
film=<target> labels=<name> tabs=<name> eval=<js> expect=<js> hover=<target>
rightclick=<target> (secondary button: context menus)
drag=<target>><dx>,<dy> (JSON: drag, dx, dy, steps, gap, hold)
swipe=<target>><dx>,<dy> pinch=<target>><scale> (with --touch true)
target: <label> | label:<label> | key:<semantics identifier> | x,y`;
@@ -113,6 +114,12 @@ try {
await delay(step.wait ?? settle);
break;
}
case 'rightclick': {
const hit = await page.rightClick(value, step.timeout);
log(` right-clicked ${describe(parseTarget(value))} at ${Math.round(hit.x)},${Math.round(hit.y)}`);
await delay(step.wait ?? settle);
break;
}
case 'waitfor': await page.waitFor(value, step.timeout ?? 10000); break;
case 'files': await page.armFiles(String(value).split(',').map((p) => resolve(p))); break;
case 'type': await page.type(String(value)); await delay(step.wait ?? settle); break;
+11 -2
View File
@@ -121,6 +121,14 @@ export function flutterPage(browser, log, { touch = false } = {}) {
await tap(point);
return point;
},
/** Clicks the secondary (right) mouse button on [target] (context menus). */
async rightClick(target, timeout) {
const { x, y } = await locate(target, timeout);
await send('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y });
await send('Input.dispatchMouseEvent', { type: 'mousePressed', x, y, button: 'right', buttons: 2, clickCount: 1 });
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x, y, button: 'right', buttons: 0, clickCount: 1 });
return { x, y };
},
waitFor: (target, timeout) => locate(target, timeout),
/** Answers the next file chooser the page opens with [paths] (absolute). */
async armFiles(paths) {
@@ -148,9 +156,10 @@ export function flutterPage(browser, log, { touch = false } = {}) {
const key = parts.pop();
const bits = { Alt: 1, Control: 2, Meta: 4, Shift: 8 };
const modifiers = parts.reduce((m, p) => m | (bits[p] ?? 0), 0);
const codes = { Enter: 13, Escape: 27, Tab: 9, Backspace: 8, ArrowDown: 40, ArrowUp: 38, ArrowLeft: 37, ArrowRight: 39, "/": 191 };
const codes = { Enter: 13, Escape: 27, Tab: 9, Backspace: 8, ArrowDown: 40, ArrowUp: 38, ArrowLeft: 37, ArrowRight: 39, "/": 191, '=': 187, '-': 189 };
const digit = /^\d$/.test(key);
const code = key === '/' ? 'Slash' : digit ? `Digit${key}` : /^[a-z]$/i.test(key) ? `Key${key.toUpperCase()}` : key;
const named = { '/': 'Slash', '=': 'Equal', '-': 'Minus' };
const code = named[key] ? named[key] : digit ? `Digit${key}` : /^[a-z]$/i.test(key) ? `Key${key.toUpperCase()}` : key;
const vk = codes[key] ?? (key.length === 1 ? key.toUpperCase().charCodeAt(0) : 0);
const text = key === 'Enter' ? '\r' : key.length === 1 && !modifiers ? key : undefined;
const base = { key, code, windowsVirtualKeyCode: vk, modifiers, text };