Skip to main content

Module robot_helpers

Module robot_helpers 

Source
Expand description

Common helper functions for robot tests

These helpers work with cranpose::SemanticElement to find and interact with UI elements during robot testing.

Structs§

ScreenshotDifferenceStats
ScreenshotPixelDifference
ScrollConfig
Configuration for scroll-into-view helpers so we don’t need too many arguments.

Enums§

TabAxis

Functions§

bounds_span
capture_screenshot
Capture a full screenshot from the running robot app.
changed_pixel_count
Count pixels that differ between two screenshots by more than channel_threshold on any RGBA channel.
changed_pixel_count_in_region
Count pixels that differ within a sub-region (x, y, w, h) of two screenshots.
collect_by_text_exact
collect_tab_bounds
collect_text_prefix_counts
count_text_in_tree
crop_screenshot
Crops a rectangular region from a screenshot.
crop_screenshot_logical
detect_tab_axis
exit_with_timeout
find_bounds_by_text
find_button
Find a clickable element (button) containing the specified text.
find_button_center
Find a clickable element (button) containing the specified text. Returns center coordinates (x, y).
find_button_exact_in_semantics
Find button by exact text in semantics tree.
find_button_in_semantics
Find button by text in semantics tree. Convenience wrapper around find_in_semantics + find_button.
find_by_text_recursive
Recursively search for text in semantic elements. Returns the element containing the text.
find_center_by_text
find_clickables_in_range
Find all clickable elements in a specific Y range. Returns a list of (label, x, y) tuples sorted by x position.
find_element_by_text_exact
find_in_semantics
Search the semantic tree from Robot, applying a finder function.
find_in_subtree_by_text
find_text
Find an element by text content (partial match), returning bounds (x, y, width, height).
find_text_by_prefix
Find an element whose text starts with the given prefix. Returns bounds (x, y, width, height) and the full text.
find_text_by_prefix_in_semantics
Find element by text prefix in semantics tree. Returns bounds (x, y, width, height) and the full text content. Useful for parsing dynamic text like “Stats: C=5 E=3 D=2”.
find_text_center
Find an element by text content, returning center coordinates (x, y).
find_text_exact
Find an element by exact text content, returning bounds (x, y, width, height).
find_text_in_semantics
Find element by text in semantics tree (Robot wrapper).
has_text
Check if an element or any of its children contains the specified text.
logical_region_to_pixel_bounds
normalize_screenshot_region
Normalize a floating-point screenshot region into a stable pixel grid with bilinear sampling.
parse_slider_value
Parse “label: value” text from a slider label, returning the numeric value.
print_semantics_with_bounds
root_bounds
sample_screenshot_pixel_logical
screenshot_difference_stats
Count differing pixels and report the strongest difference between two screenshots of equal dimensions. The difference metric is the maximum per-channel absolute difference.
screenshot_logical_size
screenshot_pixel
Returns pixel RGBA at (x, y) from a screenshot.
scroll_down
Scroll down by dragging from from_y to to_y at center_x.
scroll_prefix_into_view
Scroll until a semantics node with the given prefix text is visible. Returns bounds + full text (x, y, w, h, text).
scroll_text_into_view
Scroll until a semantics node with exactly matching text is visible. Returns bounds (x, y, w, h).
scroll_up
Scroll up by dragging from from_y to to_y at center_x.
set_slider_fraction
Set a slider to a given fraction [0, 1] and return the parsed value.
union_bounds
visible_bounds_in_viewport
y_is_visible
Check whether a given Y coordinate falls within the visible viewport (with 28px margin top and bottom).