Skip to main content
Glama

assert_attribute

Verify an element's attribute or property equals, contains, or matches a pattern; waits for the element and fails with expected vs actual.

Instructions

Test step: check that an element's attribute or property equals (default), contains, or matches a regular expression, e.g. that a button is disabled or an input's value is 'standard_user'. Waits for the element to exist; a missing attribute counts as an empty string. Fails as a tool error showing expected vs actual.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoequals = exact match (default); contains = substring; matches = JavaScript regular expression.equals
nameYesAttribute or property to check, e.g. 'value', 'disabled', 'href', or 'class'.
expectedYesExpected value or pattern, e.g. 'true' for a disabled button.
selectorYesHow to find the element, e.g. { by: 'css', value: '#login-button' } or { by: 'id', value: 'user-name' }. Prefer id, name, or a short CSS selector.
timeoutMsNoHow long to wait for the element to exist, in milliseconds (default 10000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.3.0
    • addedInput schema / properties / expected / description
      Added value: +"Expected value or pattern, e.g. 'true' for a disabled button."
    • addedInput schema / properties / mode / description
      Added value: +"equals = exact match (default); contains = substring; matches = JavaScript regular expression."
    • addedInput schema / properties / name / description
      Added value: +"Attribute or property to check, e.g. 'value', 'disabled', 'href', or 'class'."
    • addedInput schema / properties / selector / description
      Added value: +"How to find the element, e.g. { by: 'css', value: '#login-button' } or { by: 'id', value: 'user-name' }. Prefer id, name, or a short CSS selector."
    • addedInput schema / properties / selector / properties / by / description
      Added value: +"Locator strategy: css, xpath, id, name, class/className, tag/tagName, linkText, or partialLinkText."
    • addedInput schema / properties / selector / properties / value / description
      Added value: +"The locator for that strategy, e.g. '#login-button' for css, 'user-name' for id, or //button[@type=\"submit\"] for xpath."
    • addedInput schema / properties / timeoutMs / description
      Added value: +"How long to wait for the element to exist, in milliseconds (default 10000)."
  2. First observedv0.1.2

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the implicit wait for element existence, the edge-case rule that a missing attribute equals an empty string, and the failure semantics (tool error showing expected vs actual). Remaining gaps are minor, such as interaction with timeoutMs beyond the schema default.

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?

Three dense sentences, front-loaded with the core assertion behavior, followed by edge-case and failure semantics. No filler or redundancy.

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?

With no output schema, the description usefully explains the success/failure outcome (tool error with expected vs actual) and the wait/missing-attribute behavior, which is enough to invoke it correctly. It could say slightly more about how the wait interacts with timeoutMs, but nothing critical is missing.

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 every parameter (mode, name, expected, selector, timeoutMs) is already documented in the schema. The description restates the mode semantics and examples but adds no syntax or format detail beyond what the schema provides, so the baseline of 3 is appropriate.

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 (check/assert) applied to a specific resource (an element's attribute or property) with concrete examples ('a button is disabled', an input's value). It is clearly distinguishable from siblings like get_attribute (reads a value) and assert_text/assert_visible (different assertions).

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

Usage Guidelines4/5

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

The 'Test step:' prefix and the enumeration of comparison modes give clear context for when this assertion tool applies, and the examples make the use case concrete. However, it never names alternatives or exclusions (e.g. use get_attribute to read rather than assert, or assert_visible for visibility), leaving that routing to inference.

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