Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorYesCSS selector to wait for
timeoutNoMaximum time to wait in milliseconds (default: 30000)

Implementation Reference

  • 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}`); } }, };
  • 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)'), }),
  • 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];

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dsouza-anush/brightdata-mcp-heroku'

If you have feedback or need assistance with the MCP directory API, please join our Discord server