Skip to main content
Glama

Validate selector or locator

validate-selector
Read-onlyIdempotent

Check a CSS or Playwright locator on a live page to confirm validity, count matches, see samples, and get a sturdier verified locator for reliable test actions.

Instructions

Check a CSS selector, Playwright selector or locator (getByRole/getByTestId…, .first(), .filter()) on a live page: validity, match count (actions need exactly 1), sample matches and a sturdier verified locator for each. Accepts storageState/headers/actions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesFull URL of the live page to test against (http/https)
actionsNoSteps run after load to reach a state (modal, step 3)
headersNoExtra HTTP headers, e.g. Authorization
selectorYesSelector or locator, e.g. getByRole('button', { name: 'Save' })
viewportNo
timeoutMsNoOverall limit in ms (default 45000)
projectRootNoProject whose Playwright launches the browser (default: server root)
storageStateNoLogged-in session: storageState JSON inside the project, e.g. playwright/.auth/user.json

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.2

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint/idempotentHint/openWorldHint, so the description earns credit for adding real context: it needs a live, possibly authenticated page (storageState/headers) and can be driven through intermediate states via actions. It stops short of noting the mild tension that 'actions' can click/fill the live page while the tool is annotated read-only, or any rate/timeout behavior beyond what the schema states.

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?

Front-loaded with the verb and fully packed into two sentences with no filler; every clause (locator kinds, live page, output list, accepted inputs) earns its place. The parenthetical locator examples make it dense but readable rather than padded.

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 an 8-parameter tool with nested action objects and no output schema, the description usefully enumerates what the call returns, which compensates for the absent output schema. The remaining gaps (defaults, pagination-style limits, behavior when zero or many matches occur) are minor and partly covered by the schema.

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

Parameters4/5

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

Schema description coverage is already 88%, so the baseline is 3, and the description goes slightly beyond by calling out storageState, headers and actions as accepted inputs and explaining the selector semantics with concrete locator syntax. It does not clarify defaults for timeoutMs or projectRoot, but the schema covers those.

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 (validate/check) and resource (CSS selector, Playwright selector or locator) plus the exact scope: against a live page. It enumerates the outputs the agent gets back (validity, match count, sample matches, sturdier verified locator), which cleanly distinguishes it from siblings like inspect-page or run-test that operate on whole pages or suites.

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

Usage Guidelines3/5

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

The parenthetical 'actions need exactly 1' gives an implied usage rule (validate before acting), and 'on a live page' signals the required context, but there is no explicit when-to-use/when-not statement and no sibling is named as the alternative. The agent must infer that this is the pre-flight check rather than, say, run-test or suggest-fix.

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