mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 06:00:42 +00:00
feat(browser): add coordinate click action
Co-authored-by: Daniel Lutts <daniellutts@10-19-94-204.dynapool.wireless.nyu.edu>
This commit is contained in:
@@ -75,6 +75,37 @@ export function registerBrowserElementCommands(
|
||||
});
|
||||
});
|
||||
|
||||
browser
|
||||
.command("click-coords")
|
||||
.description("Click viewport coordinates")
|
||||
.argument("<x>", "Viewport x coordinate")
|
||||
.argument("<y>", "Viewport y coordinate")
|
||||
.option("--target-id <id>", "CDP target id (or unique prefix)")
|
||||
.option("--double", "Double click", false)
|
||||
.option("--button <left|right|middle>", "Mouse button to use")
|
||||
.option("--delay-ms <ms>", "Delay between mouse down/up", (v: string) => Number(v))
|
||||
.action(async (xRaw: string, yRaw: string, opts, cmd) => {
|
||||
const x = Number(xRaw);
|
||||
const y = Number(yRaw);
|
||||
await runElementAction({
|
||||
cmd,
|
||||
body: {
|
||||
kind: "clickCoords",
|
||||
x,
|
||||
y,
|
||||
targetId: normalizeOptionalString(opts.targetId),
|
||||
doubleClick: Boolean(opts.double),
|
||||
button: normalizeOptionalString(opts.button),
|
||||
delayMs: Number.isFinite(opts.delayMs) ? opts.delayMs : undefined,
|
||||
},
|
||||
successMessage: (result) => {
|
||||
const url = (result as { url?: unknown }).url;
|
||||
const suffix = typeof url === "string" && url ? ` on ${url}` : "";
|
||||
return `clicked ${x},${y}${suffix}`;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
browser
|
||||
.command("type")
|
||||
.description("Type into an element by ref from snapshot")
|
||||
|
||||
Reference in New Issue
Block a user