1 min read

Library API

Table of Contents

Session Lifecycle

TuiSession handles spawning, terminal interaction, and bounded cleanup:

use ttry::{LaunchOptions, TuiSession};

let session = TuiSession::launch(
    LaunchOptions::new("./bin/my-tui")
        .size(100, 30)
        .env("TERM", "xterm-256color")
)?;

Locators & Assertions

Locators are live queries against the rendered PTY screen:

// Wait for text on screen
session.wait_for_text("Ready", Duration::from_secs(3))?;

// Query element locator
let heading = session.get_by_text("Main Menu");
session.expect(heading).to_be_visible()?;

// Screen-wide assertion
session.expect_screen().to_contain_text("Main Menu")?;

Keyboard Input

session.keyboard().press("ctrl+p")?;
session.keyboard().type_text("search query", None)?;
session.keyboard().press("Enter")?;