Skip to main content
Glama

wait_for_element

Waits for a web element to appear or disappear. Specify a CSS selector and optionally a timeout and target state (attached, detached, visible, hidden).

Instructions

Wait for an element to appear or disappear

Input Schema

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

Implementation Reference

  • Zod schema for the wait_for_element tool, defining selector (string), timeout (number, default 30000), and state (enum: attached/detached/visible/hidden, 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 within the server's tool list, providing name 'wait_for_element', description 'Wait for an element to appear or disappear', and the inputSchema with selector, timeout, and state properties.
    {
      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']
      }
    },
  • Handler implementation that parses args with WaitForElementSchema, calls Playwright's page.waitForSelector with the selector, timeout, and state, then returns a text message confirming the element state.
    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}`
          }
        ]
      };
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose key behavioral traits like timeout behavior (error vs. silent failure), whether it blocks, or if it returns a value. The agent is left to infer these from the schema's 'timeout' parameter.

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

Conciseness3/5

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

The description is a single sentence with no fluff, but it is too brief to convey important context. It is appropriately sized but lacks substance beyond the tool name.

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 does not explain what the tool returns (e.g., boolean, void), error behavior, or side effects, leaving significant gaps for an AI agent.

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?

The input schema has 100% description coverage, so the description adds no additional meaning beyond what the schema already provides. Baseline score of 3 applies.

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

Purpose4/5

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

The description clearly states 'Wait for an element to appear or disappear', which is a specific verb+resource combination. However, it does not explicitly differentiate from sibling tools like 'click_element' or 'type_text', though those have different purposes.

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 on when to use this tool compared to alternatives, such as checking if an element exists or waiting for page load. The description lacks any context about appropriate usage scenarios.

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/Wladastic/mcp-browser-server'

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