Skip to main content
Glama

wait_for_element

Wait for an element to exist or be visible, then return its tag and state. Use before interacting with content that loads later, such as spinners or lazy lists.

Instructions

Wait for an element to exist in the page, or with visible: true to also be displayed, then return its tag and state (displayed, enabled). Use it before acting on content that loads later: spinners finishing, lazy lists, dialogs, single-page-app transitions. click, type, and get_text already wait for their own target, so use this to wait for something else first. For URL or title changes, use wait_for_page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
visibleNoAlso require the element to be displayed, not just present in the DOM (default false).
selectorYesHow to find the element, e.g. { by: 'css', value: '#login-button' } or { by: 'id', value: 'user-name' }. Prefer id, name, or a short CSS selector.
timeoutMsNoHow long to wait, in milliseconds (default 10000, max 60000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.3.0
    • addedInput schema / properties / selector / description
      Added value: +"How to find the element, e.g. { by: 'css', value: '#login-button' } or { by: 'id', value: 'user-name' }. Prefer id, name, or a short CSS selector."
    • addedInput schema / properties / selector / properties / by / description
      Added value: +"Locator strategy: css, xpath, id, name, class/className, tag/tagName, linkText, or partialLinkText."
    • addedInput schema / properties / selector / properties / value / description
      Added value: +"The locator for that strategy, e.g. '#login-button' for css, 'user-name' for id, or //button[@type=\"submit\"] for xpath."
    • addedInput schema / properties / timeoutMs / description
      Added value: +"How long to wait, in milliseconds (default 10000, max 60000)."
    • addedInput schema / properties / visible / description
      Added value: +"Also require the element to be displayed, not just present in the DOM (default false)."
  2. First observedv0.1.2

TDQS

A4.4/5.0
Behavior4/5

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

No annotations are provided, so the description carries the burden. It discloses the default existence-vs-visibility semantics, the returned state fields (displayed, enabled), and the timing behavior implied by 'wait'. It does not state what happens on timeout (error vs return) or block/polling behavior, which is a meaningful gap for a waiting primitive with no annotation coverage.

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?

Four front-loaded sentences, each earning its place: what it does and returns, when to use it, when not to, and where to go instead. No filler or redundancy.

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

Completeness4/5

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

Complete for a 3-param waiting tool with full schema coverage and no output schema: purpose, semantics, and routing to siblings are all covered. The remaining gap is timeout/error behavior, which matters for a blocking primitive but is partially inferable from the timeoutMs parameter and default.

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 both selector and visible are already fully documented in the schema with examples and defaults. The description reinforces the visible toggle but adds no syntax or format detail beyond the schema. Baseline 3 applies when the schema does the heavy lifting.

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

Purpose5/5

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

States a specific verb+resource (wait for element) with explicit scope: existence by default, visibility with visible:true, and return payload (tag and state). Clearly distinguishes itself from siblings like click/type/get_text which self-wait, and routes URL/title waits to wait_for_page.

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

Usage Guidelines5/5

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

Explicit when-to-use with concrete scenarios (spinners finishing, lazy lists, dialogs, SPA transitions), an explicit when-not-to-use note ('click, type, and get_text already wait for their own target'), and a named alternative for URL/title changes (wait_for_page). Nothing left to inference.

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