feat(browser): add scrollintoview action

This commit is contained in:
Peter Steinberger
2026-01-12 21:56:08 +00:00
parent 2faf7cea93
commit 6857f16609
5 changed files with 87 additions and 0 deletions

View File

@@ -1160,6 +1160,25 @@ export async function responseBodyViaPlaywright(opts: {
};
}
export async function scrollIntoViewViaPlaywright(opts: {
cdpUrl: string;
targetId?: string;
ref: string;
timeoutMs?: number;
}): Promise<void> {
const page = await getPageForTargetId(opts);
ensurePageState(page);
const timeout = normalizeTimeoutMs(opts.timeoutMs, 20_000);
const ref = requireRef(opts.ref);
const locator = refLocator(page, ref);
try {
await locator.scrollIntoViewIfNeeded({ timeout });
} catch (err) {
throw toAIFriendlyError(err, ref);
}
}
export async function navigateViaPlaywright(opts: {
cdpUrl: string;
targetId?: string;