Skip to main content
Glama

wait_for

Pauses script execution until a specified web element becomes available on the page, using CSS selectors to identify elements and optional timeout settings.

Instructions

Wait for an element to appear on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element to wait for
timeoutNoTimeout in milliseconds (default: 5000)

Implementation Reference

  • Handler function for the 'wait_for' MCP tool. Delegates to browser.waitFor method.
    handler: async ({ selector, timeout = 5000 }) => { await browser.waitFor(selector, timeout); return { success: true, message: `Element ${selector} appeared within ${timeout}ms` }; }
  • Input schema definition for the 'wait_for' tool.
    inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to wait for' }, timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' } }, required: ['selector'] },
  • Full registration of the 'wait_for' tool in createPlaywrightTools array.
    { name: 'wait_for', description: 'Wait for an element to appear on the page', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to wait for' }, timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' } }, required: ['selector'] }, handler: async ({ selector, timeout = 5000 }) => { await browser.waitFor(selector, timeout); return { success: true, message: `Element ${selector} appeared within ${timeout}ms` }; } },
  • Core waitFor helper method in SimpleBrowser class that uses Playwright's waitForSelector.
    async waitFor(selector, timeout = 5000) { await this.ensureLaunched(); await this.page.waitForSelector(selector, { timeout }); }

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/zypin-testing/zypin-mcp'

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