scraping_browser_wait_for
Wait for a specific element to become visible on a webpage using a CSS selector, ensuring reliable interaction during web scraping and browser automation.
Instructions
Wait for an element to be visible on the page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector to wait for | |
| timeout | No | Maximum time to wait in milliseconds (default: 30000) |
Implementation Reference
- browser_tools.js:177-194 (handler)Complete implementation of the scraping_browser_wait_for tool, including the execute handler that uses Puppeteer's waitForSelector to wait for the specified CSS selector to appear on the page.let scraping_browser_wait_for = { name: 'scraping_browser_wait_for', description: 'Wait for an element to be visible on the page', parameters: z.object({ selector: z.string().describe('CSS selector to wait for'), timeout: z.number().optional() .describe('Maximum time to wait in milliseconds (default: 30000)'), }), execute: async({selector, timeout})=>{ const page = await (await require_browser()).get_page(); try { await page.waitForSelector(selector, {timeout: timeout||30000}); return `Successfully waited for element: ${selector}`; } catch(e){ throw new UserError(`Error waiting for element ${selector}: ${e}`); } }, };
- browser_tools.js:180-184 (schema)Zod schema defining the input parameters for the tool: selector (string, required) and timeout (number, optional, defaults to 30000ms).parameters: z.object({ selector: z.string().describe('CSS selector to wait for'), timeout: z.number().optional() .describe('Maximum time to wait in milliseconds (default: 30000)'), }),
- browser_tools.js:307-320 (registration)The tool is registered (included) in the exported 'tools' array, which is conditional on the presence of the API_TOKEN environment variable.export const tools = process.env.API_TOKEN ? [ scraping_browser_navigate, scraping_browser_go_back, scraping_browser_go_forward, scraping_browser_links, scraping_browser_click, scraping_browser_type, scraping_browser_wait_for, scraping_browser_screenshot, scraping_browser_get_text, scraping_browser_get_html, scraping_browser_scroll, scraping_browser_scroll_to, ] : [scraping_browser_activation_instructions];