Skip to main content
Glama
Lokii0911
by Lokii0911

wait_for_element

Wait for a web element to exist or become visible by specifying a locator strategy, value, timeout, and visibility requirement. Ensures element is ready for interaction.

Instructions

Wait until an element exists, or until it is visible when requested.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strategyYes
valueYes
timeout_secondsNo
visibleNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The wait_for_element method on BrowserManager – the main handler that waits for an element and returns a summary of it.
    def wait_for_element(
        self,
        strategy: LocatorStrategy,
        value: str,
        timeout_seconds: float = 10,
        visible: bool = True,
    ) -> ElementSummary:
        with self._lock:
            element = self._wait_for_element(strategy, value, timeout_seconds, visible=visible)
            return self._summarize_element(element)
  • _wait_for_element – internal helper that uses Selenium WebDriverWait with configurable visibility/clickable conditions.
    def _wait_for_element(
        self,
        strategy: LocatorStrategy,
        value: str,
        timeout_seconds: float | None,
        *,
        clickable: bool = False,
        visible: bool = True,
    ) -> WebElement:
        driver = self._require_driver()
        by = LOCATOR_MAP[strategy]
        timeout = timeout_seconds if timeout_seconds is not None else self._settings.page_load_timeout_seconds
        condition = EC.presence_of_element_located((by, value))
        if clickable:
            condition = EC.element_to_be_clickable((by, value))
        elif visible:
            condition = EC.visibility_of_element_located((by, value))
        try:
            return WebDriverWait(driver, timeout).until(condition)
        except TimeoutException as exc:
            raise BrowserError(f"Element not found: {strategy}={value}") from exc
  • The @mcp.tool() decorator registration of wait_for_element as an MCP tool.
    @mcp.tool()
    def wait_for_element(
        strategy: LocatorStrategy,
        value: str,
        timeout_seconds: float = 10,
        visible: bool = True,
    ) -> dict[str, Any]:
        """Wait until an element exists, or until it is visible when requested."""
        return _run("wait_for_element", browser.wait_for_element, strategy, value, timeout_seconds, visible)
  • LocatorStrategy type definition (Literal) used as the strategy parameter schema.
    LocatorStrategy = Literal[
        "id",
        "name",
        "css selector",
        "xpath",
        "link text",
        "partial link text",
        "tag name",
        "class name",
    ]
  • ElementSummary Pydantic model – the return type schema for wait_for_element.
    class ElementSummary(BaseModel):
        tag_name: str
        text: str
        enabled: bool
        displayed: bool
        selected: bool
        attributes: dict[str, Any] = Field(default_factory=dict)
Behavior3/5

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

Describes the core behavior (waiting for existence or visibility), but does not disclose timeout behavior (error vs return), nor the impact on the element or page state. With no annotations, more details would be beneficial.

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?

Extremely concise (one sentence), but lacks structure and depth. While not verbose, it is too terse to fully convey the tool's behavior and usage.

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 the complexity of 4 parameters and the existence of an output schema, the description is insufficient. It does not explain return values, timeout handling, or how to combine parameters effectively. Siblings like find_element indicate need for clearer differentiation.

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

Parameters2/5

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

Description adds no value beyond the input schema. It does not explain the strategy, value, timeout, or visible parameters. The schema provides defaults and enums, but the description offers no additional context.

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?

Description clearly indicates the tool waits for an element to exist or become visible, with explicit mention of the waiting behavior and visibility option. However, it lacks specificity about the return value and does not differentiate strongly from siblings like find_element.

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 explicit guidance on when to use this tool vs alternatives such as find_element or click. The phrase 'when requested' is vague, and there is no mention of scenarios where waiting is preferred.

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/Lokii0911/SeleniumMCP'

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