Skip to main content
Glama

wait_for_element

Monitors web elements for specific states (attached, detached, visible, hidden) using CSS selectors, ensuring synchronization in browser automation workflows within AutoProbeMCP.

Instructions

Wait for an element to appear or disappear

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element
stateNoState to wait forvisible
timeoutNoTimeout in milliseconds

Implementation Reference

  • The main handler function for the 'wait_for_element' tool. It validates input using WaitForElementSchema, waits for the specified selector using Playwright's waitForSelector with timeout and state, and returns a success message.
    case 'wait_for_element': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = WaitForElementSchema.parse(args); await currentPage.waitForSelector(params.selector, { timeout: params.timeout, state: params.state as any }); return { content: [ { type: 'text', text: `Element ${params.selector} is now ${params.state}` } ] }; }
  • Zod schema defining the input parameters for the wait_for_element tool: selector (required string), timeout (default 30000ms), state (enum with default 'visible').
    const WaitForElementSchema = z.object({ selector: z.string(), timeout: z.number().default(30000), state: z.enum(['attached', 'detached', 'visible', 'hidden']).default('visible') });
  • src/index.ts:256-280 (registration)
    Tool registration in the ListTools response, including name, description, and inputSchema matching the Zod schema.
    { name: 'wait_for_element', description: 'Wait for an element to appear or disappear', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element' }, timeout: { type: 'number', default: 30000, description: 'Timeout in milliseconds' }, state: { type: 'string', enum: ['attached', 'detached', 'visible', 'hidden'], default: 'visible', description: 'State to wait for' } }, required: ['selector'] } },

Other Tools

Related 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/Wladastic/AutoProbeMCP'

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