Skip to content

feat: add text locators - #149

Draft
cpendery (cpendery) wants to merge 16 commits into
mainfrom
feat/text-locators-core
Draft

feat: add text locators#149
cpendery (cpendery) wants to merge 16 commits into
mainfrom
feat/text-locators-core

Conversation

@cpendery

@cpendery cpendery (cpendery) commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary

  • add lazy, reusable locators across Rust, Python, and JavaScript
  • expose Playwright-style getByText / getByStyle APIs (get_by_text / get_by_style in Python and Rust)
  • allow text and contiguous per-row style-run stages to be chained in either order and re-resolved for every read or action
  • support literal/regex matching, viewport or full scrollback, whitespace normalization, anchors, match locations, and any / unique / first / last / nth selection
  • click the middle matched cell and highlight selected matches in the live monitor and SVG screenshots
  • expose the visible CLI family as find|expect|click|highlight text "T", all with the same selector and optional style flags
  • make click text auto-wait; retain wait text only as a hidden compatibility alias
  • pass typed locator stage arrays and style/action parameters across N-API and PyO3 with no locator JSON serialization
  • keep findText / find_text, waitText / wait_text, and expectText / expect_text compatibility helpers on the generic locator engine
  • version the daemon protocol independently so older daemons restart before receiving revised query requests
  • consolidate the implementation onto one generic action stack; the cleanup revisions remove 1,560 lines and add 942, a net reduction of 618 lines

Examples

await terminal
  .getByText("Product 2 Add to cart", { whitespace: "normalize" })
  .getByText("Add to cart")
  .click();

await terminal
  .getByStyle({ bold: true })
  .getByText("Warning")
  .highlight();
await (
    terminal
    .get_by_text("Settings Save", whitespace="normalize")
    .get_by_style(TextStyle(bold=True))
    .get_by_text("Save")
    .click()
)
tui-test find text "Add to cart" --fg green
tui-test expect text "Add to cart" --fg green --timeout 5000
tui-test click text "Add to cart" --fg green --timeout 5000
tui-test highlight text "Add to cart" --fg green

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo clippy -p tui-test-rs --all-targets --no-default-features -- -D warnings
  • cargo build
  • cargo test --workspace -- --test-threads=1
  • python -m unittest discover -s bindings/python/tests
  • python bindings/python/scripts/generate_stubs.py --check
  • npm run test:node --prefix bindings/js

This draft consolidates and supersedes #150, #151, #152, and #154.

Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Signed-off-by: cpendery <cpendery@vt.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant