captureSnapshot
Capture a full-page snapshot of a webpage, including scrolling, waiting, and automatic trimming, to reduce HTML token usage and enable efficient web interactions.
Instructions
捕获网页的完整快照,支持滚动、等待和自动修剪功能
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageDescription | No | 页面描述(默认'Auto snapshot page') | |
| pageName | No | 页面名称(默认'snapshot') | |
| scrollDelay | No | 滚动间隔时间(毫秒,默认5000) | |
| scrolls | No | 滚动次数(默认1) | |
| trim | No | 是否修剪重复内容(默认true) | |
| url | Yes | 要捕获的网页URL | |
| wait | No | 初始等待时间(毫秒,默认5000) |
Implementation Reference
- lib/tab.js:150-176 (handler)The main handler function for capturing a snapshot of the current browser tab. It races against modal state changes to safely capture URL, title, ARIA tree snapshot, console messages, downloads, and modal states.async captureSnapshot() { let tabSnapshot; const modalStates = await this._raceAgainstModalStates(async () => { const snapshot = await this.page._snapshotForAI(); tabSnapshot = { url: this.page.url(), title: await this.page.title(), ariaSnapshot: snapshot, modalStates: [], consoleMessages: [], downloads: this._downloads, }; }); if (tabSnapshot) { // Assign console message late so that we did not lose any to modal state. tabSnapshot.consoleMessages = this._recentConsoleMessages; this._recentConsoleMessages = []; } return tabSnapshot ?? { url: this.page.url(), title: '', ariaSnapshot: '', modalStates, consoleMessages: [], downloads: [], }; }