Skip to main content
Glama

assert_text

Verify an element's visible text matches expected content using exact, substring, or regex comparison, and fail the test with expected vs actual if the acceptance check differs.

Instructions

Test step: check that an element's visible text equals, contains (default), or matches a regular expression. Waits for the element to be visible, then checks once (it does not wait for the text to change). Passes with the actual text, or fails as a tool error showing expected vs actual, so it works as an acceptance check. Use get_text to just read text without a pass/fail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoequals = exact match; contains = substring (default); matches = JavaScript regular expression.contains
trimNoTrim whitespace from the actual text before comparing (default true).
expectedYesText or pattern the element's text should match, e.g. 'Epic sadface: Username is required'.
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 become visible, 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: +"Text or pattern the element's text should match, e.g. 'Epic sadface: Username is required'."
    • addedInput schema / properties / mode / description
      Added value: +"equals = exact match; contains = substring (default); matches = JavaScript regular expression."
    • 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 become visible, in milliseconds (default 10000)."
    • addedInput schema / properties / trim / description
      Added value: +"Trim whitespace from the actual text before comparing (default true)."
  2. First observedv0.1.2

TDQS

A4.7/5.0
Behavior5/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 so well: it discloses the visibility wait, the single-check behavior (no retry on text change), the pass payload (actual text), and the failure mode (tool error with expected vs actual). This is rich behavioral context beyond anything in the schema.

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?

Four sentences, front-loaded with the core action, and each sentence adds distinct value (semantics, wait behavior, result contract, alternative). No filler.

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

Completeness5/5

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

For a nested-selector assertion tool with no output schema and no annotations, the definition covers the pass/fail contract, timing behavior, and sibling routing. Nothing essential for correct invocation 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 coverage is 100%, so the schema already documents all five parameters including mode enum, trim default, and timeout. The description restates the mode options but adds no syntax or format detail beyond what the schema provides, so the baseline 3 applies.

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 and resource ('check that an element's visible text equals, contains, or matches a regex') and immediately differentiates itself from the sibling get_text. An agent can identify the tool's role without opening the schema.

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

Usage Guidelines5/5

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

Frames the tool as an acceptance check and names the alternative explicitly ('Use get_text to just read text without a pass/fail'), giving a clear when-to-use and when-not condition. The single-check semantics ('does not wait for the text to change') further disambiguate it from wait_for_element.

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