Skip to main content
Glama

browser.wait_for_selector

Read-only

Waits for a CSS selector to reach a specified state (visible, hidden, attached, detached) and returns once true. Prevents timing issues by raising a timeout if the condition never occurs.

Instructions

Wait for a CSS selector to reach a specific state (visible, hidden, attached, detached). Returns when the condition is met or raises on timeout.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNoCondition to wait for, as in Playwright's wait_for_selector.visible
selectorYesCSS or Playwright selector.
session_idNoTarget session id, from browser.create_session or browser.list_sessions. Optional when exactly one session is live; observe and act tools create one when none is.
timeout_msNoHow long to wait before failing.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.8.1
  2. Removedv1.4.2
  3. Changed3 schema fields changedv1.0.3
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / session_id / maxLength
      Added value: +120
    • addedInput schema / properties / session_id / minLength
      Added value: +1
  4. First observedv0.5.0

TDQS

A3.6/5.0
Behavior4/5

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

The description explicitly states the completion condition (selector reaches the requested state) and the failure behavior (raises on timeout), which is useful beyond the annotations. Annotations already cover readOnlyHint=true and destructiveHint=false, so the safety profile is clear. It does not mention possible session creation, but that detail is available in the session_id parameter description.

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 sentence that front-loads the verb and resource, lists the relevant states, and states the timeout behavior. There is no filler or repetition of schema fields, making it highly efficient.

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?

For a simple synchronization tool, the description covers the core contract: what condition to wait for and what happens on timeout. The schema fully documents parameters and defaults, and annotations cover the read-only/destructive profile. The main residual gap is that the return value is not described, but the absence of an output schema makes this less critical.

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 baseline applies and the description does not need to compensate. The description adds no substantive parameter meaning beyond saying 'CSS selector', which is actually narrower than the schema's 'CSS or Playwright selector'. State, timeout, and session_id are all already well documented in the input schema.

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 the action (wait), the resource (selector), and the specific completion states (visible, hidden, attached, detached). It is easy to distinguish from siblings like list_sessions or screenshot, though it does not explicitly contrast with find_elements or observe. The description calls it a CSS selector while the schema says 'CSS or Playwright selector', a minor narrowing that keeps it from being fully precise.

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?

There is no guidance on when to use this tool versus siblings like find_elements or observe, and no exclusions or alternatives are mentioned. The verb 'Wait' implies a synchronization use case, but the description leaves the decision entirely to the agent's inference. Session-related prerequisites are documented in the schema, not in the description.

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