Skip to main content
Glama
Yan-Vi
by Yan-Vi

set_locator

Add or replace a locator expression on a page object method for precise element targeting in Playwright automation.

Instructions

Add or replace a locator on a page object. selector is a Playwright locator-chain EXPRESSION -- the text that goes after "page." (or the assigned scope's own expression, if this method has one via set_method_scope) -- e.g. "getByRole('button', { name: 'Submit' })" or "locator('#submit')", never a bare selector-engine string. A ${paramName} block (bare names only, not expressions) inside one of the expression's own string-literal arguments becomes a parametric method automatically -- see extractPoParams.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodYes
projectNoPath to the project root (same folder the side panel connects to). Defaults to the EASYSPEC_PROJECT environment variable if omitted.
selectorYes
pageObjectYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.4

TDQS

A3.6/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the operation adds or replaces (implying mutation) and explains the selector expression semantics in detail, including the parametric behavior. However, it does not specify side effects (e.g., whether it overwrites an existing locator, whether the page object or method must already exist, or any permissions required).

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?

The description is moderately sized but efficiently structured. It front-loads the purpose and then dives into the critical selector semantics. Every sentence adds value, though it is a bit long due to the technical detail. The structure is logical and scannable.

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

Completeness3/5

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

Given it is a mutation tool with no annotations and no output schema, the description should cover prerequisites and effects. It explains the selector format thoroughly, which is essential, but does not mention whether the page object or method must exist, what happens on replacement, or any return value. The reference to extractPoParams is left unresolved, but overall it is partially complete for an agent to call it correctly.

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 only 25% (only 'project' has a description). The description compensates significantly for the 'selector' parameter, explaining that it is a Playwright locator-chain expression and not a bare selector-engine string, plus the ${paramName} block behavior. However, it adds nothing for 'method' or 'pageObject', which remain undocumented in both schema and description.

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?

The description states a clear purpose: 'Add or replace a locator on a page object.' The verb is specific (add/replace) and the resource is identified (locator on a page object). It clearly distinguishes from siblings like remove_locator (which deletes) and set_scope (which changes scope), so an agent can tell them apart.

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 description implies usage (to set or update a locator) but does not explicitly contrast with alternatives or state when not to use it. It focuses on the selector expression format rather than providing decision guidance. No explicit exclusions or alternative tool mentions are given.

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