chore: allow reusing tab over cdp (#170)

Fixes https://github.com/microsoft/playwright-mcp/issues/164
This commit is contained in:
Pavel Feldman
2025-04-14 16:39:58 -07:00
committed by GitHub
parent e729494bd9
commit 606b898a71
7 changed files with 63 additions and 21 deletions

View File

@@ -54,7 +54,7 @@ export class Context {
currentTab(): Tab {
if (!this._currentTab)
throw new Error('Navigate to a location to create a tab');
throw new Error('No current snapshot available. Capture a snapshot of navigate to a new location first.');
return this._currentTab;
}
@@ -236,8 +236,8 @@ class Tab {
});
}
async runAndWaitWithSnapshot(callback: (tab: Tab) => Promise<void>, options?: RunOptions): Promise<ToolResult> {
return await this.run(callback, {
async runAndWaitWithSnapshot(callback: (snapshot: PageSnapshot) => Promise<void>, options?: RunOptions): Promise<ToolResult> {
return await this.run(tab => callback(tab.lastSnapshot()), {
captureSnapshot: true,
waitForCompletion: true,
...options,