Skip to main content
Glama

pilot_element_state

Check element states like visibility, enabled status, or focus in browser automation to verify UI behavior during testing or interaction.

Instructions

Check element state: visible, hidden, enabled, disabled, checked, editable, focused.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refYesElement ref or CSS selector
propertyYesState to check

Implementation Reference

  • The handler function for the 'pilot_element_state' tool, which resolves the element reference and checks its state based on the provided property.
    server.tool(
      'pilot_element_state',
      'Check element state: visible, hidden, enabled, disabled, checked, editable, focused.',
      {
        ref: z.string().describe('Element ref or CSS selector'),
        property: z.enum(['visible', 'hidden', 'enabled', 'disabled', 'checked', 'editable', 'focused']).describe('State to check'),
      },
      async ({ ref, property }) => {
        await bm.ensureBrowser();
        try {
          const page = bm.getPage();
          const resolved = await bm.resolveRef(ref);
          const locator = 'locator' in resolved ? resolved.locator : page.locator(resolved.selector);
    
          let result: boolean;
          switch (property) {
            case 'visible':  result = await locator.isVisible(); break;
            case 'hidden':   result = await locator.isHidden(); break;
            case 'enabled':  result = await locator.isEnabled(); break;
            case 'disabled': result = await locator.isDisabled(); break;
            case 'checked':  result = await locator.isChecked(); break;
            case 'editable': result = await locator.isEditable(); break;
            case 'focused':  result = await locator.evaluate((el) => el === document.activeElement); break;
          }
          return { content: [{ type: 'text' as const, text: String(result) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
        }
      }
Behavior2/5

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

No annotations provided, yet description fails to disclose return type (boolean?), error behavior when element is not found, or whether this triggers a DOM reflow. Critical gaps for a read-only inspection tool with no output schema defined.

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

Conciseness4/5

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

Single compact sentence front-loaded with the action verb 'Check'. Lists valid states efficiently. However, excessive brevity comes at the cost of omitting return value documentation that would fit in the same sentence length.

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 output schema and no annotations, the description should explain what the tool returns (presumably boolean) and error conditions. For a 2-parameter inspection tool with clear naming, it covers the input side but leaves the output side completely undocumented.

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 has 100% coverage with 'Element ref or CSS selector' and enum descriptions. Description reinforces the seven valid state values in prose, but adds no syntax details (e.g., CSS selector format) or behavioral semantics beyond the schema's existing documentation.

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?

States 'Check element state' with specific enumerated properties (visible, hidden, enabled, etc.), clearly indicating a read operation on DOM elements. Distinguishes from action-oriented siblings like pilot_click or pilot_fill, but could better differentiate from pilot_evaluate (JS execution) or pilot_page_attrs (page-level inspection).

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 versus pilot_evaluate for state checking, or when to prefer pilot_wait for waiting on states. No mention of prerequisites like element existence or visibility requirements before calling.

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/TacosyHorchata/Pilot'

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