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
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | equals = exact match; contains = substring (default); matches = JavaScript regular expression. | contains |
| trim | No | Trim whitespace from the actual text before comparing (default true). | |
| expected | Yes | Text or pattern the element's text should match, e.g. 'Epic sadface: Username is required'. | |
| selector | Yes | 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. | |
| timeoutMs | No | How long to wait for the element to become visible, in milliseconds (default 10000). |