Skip to main content
Glama

browser_wait_for_element

Wait for a specific element to appear on a webpage before proceeding with automated browser tasks, ensuring reliable interaction with dynamic content.

Instructions

Wait for an element to appear

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceIdYesInstance ID
selectorYesElement selector
timeoutNoTimeout in milliseconds

Implementation Reference

  • Core handler function that executes the tool logic: retrieves browser instance and calls Playwright's page.waitForSelector with the given selector and timeout.
    private async waitForElement(instanceId: string, selector: string, timeout: number): Promise<ToolResult> {
      const instance = this.browserManager.getInstance(instanceId);
      if (!instance) {
        return { success: false, error: `Instance ${instanceId} not found` };
      }
    
      try {
        await instance.page.waitForSelector(selector, { timeout });
        return {
          success: true,
          data: { selector, found: true },
          instanceId
        };
      } catch (error) {
        return {
          success: false,
          error: `Wait for element failed: ${error instanceof Error ? error.message : error}`,
          instanceId
        };
      }
    }
  • src/tools.ts:569-570 (registration)
    Switch statement case in executeTools method that dispatches to the waitForElement handler.
    case 'browser_wait_for_element':
      return await this.waitForElement(args.instanceId, args.selector, args.timeout || 30000);
  • Tool registration in getTools() array, including name, description, and inputSchema for validation.
      name: 'browser_wait_for_element',
      description: 'Wait for an element to appear',
      inputSchema: {
        type: 'object',
        properties: {
          instanceId: {
            type: 'string',
            description: 'Instance ID'
          },
          selector: {
            type: 'string',
            description: 'Element selector',
          },
          timeout: {
            type: 'number',
            description: 'Timeout in milliseconds',
            default: 30000
          }
        },
        required: ['instanceId', 'selector']
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions waiting behavior but lacks critical details: what happens on timeout (error, return null?), whether it polls continuously, if it waits for visibility vs. existence, or any side effects. This is a significant gap for a tool that could block execution.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for a simple tool, though this conciseness comes at the cost of detail in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., success boolean, element reference), timeout behavior, or error conditions. For a waiting tool with potential blocking effects, this leaves the agent guessing about critical operational aspects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (instanceId, selector, timeout). The description adds no additional meaning beyond implying the selector targets the element to wait for. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Wait for an element to appear' clearly states the action (waiting) and target (an element), but it's vague about what constitutes 'appearing' (e.g., visibility, existence in DOM) and doesn't differentiate from siblings like browser_wait_for_navigation. It's functional but lacks specificity for a browser automation context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active browser instance via instanceId), nor does it compare to other waiting tools like browser_wait_for_navigation. The agent must infer usage from the tool name and parameters alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/sailaoda/concurrent-browser-mcp'

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