pub struct Locator { /* private fields */ }Expand description
A lazy, re-resolving handle to one or more AT-SPI elements.
See the module-level documentation for the resolution model.
Implementations§
Source§impl Locator
impl Locator
Sourcepub fn with_timeout(&self, timeout: Duration) -> Locator
pub fn with_timeout(&self, timeout: Duration) -> Locator
Return a new locator with a per-call timeout override for auto-wait
and wait_for_* methods. Duration::ZERO means “try once, don’t
wait,” useful for negative assertions (“this element should NOT
exist right now”).
Sourcepub fn locate(&self, sub: &str) -> Locator
pub fn locate(&self, sub: &str) -> Locator
Scope a sub-expression to the nodes matched by this locator.
If sub is absolute (starts with /), it replaces the current
selector entirely. Otherwise it’s evaluated as descendants of the
current matches: (self)//sub.
Sourcepub fn nth(&self, n: usize) -> Locator
pub fn nth(&self, n: usize) -> Locator
Return a locator pinned to the n-th (0-indexed) match of this one.
Sourcepub async fn count(&self) -> Result<usize>
pub async fn count(&self) -> Result<usize>
Number of elements matched by this selector. Does not auto-wait — returns the current count, which may be zero.
Sourcepub async fn all(&self) -> Result<Vec<Locator>>
pub async fn all(&self) -> Result<Vec<Locator>>
Enumerate each match as a locator pinned by ordinal.
Each returned locator still re-resolves (so ordinal pins are
evaluated on each use, not frozen to the AT-SPI identity observed at
all() time).
Sourcepub async fn inspect_all(&self) -> Result<Vec<ElementInfo>>
pub async fn inspect_all(&self) -> Result<Vec<ElementInfo>>
Take one AT-SPI snapshot and return full metadata for every match.
More efficient than calling all() and then metadata methods on each
returned locator, which would re-snapshot per match.
Sourcepub async fn name(&self) -> Result<Option<String>>
pub async fn name(&self) -> Result<Option<String>>
Accessible name of the matched element, or None when the element
has no accessible name set.
Sourcepub async fn role(&self) -> Result<String>
pub async fn role(&self) -> Result<String>
Raw AT-SPI role name (e.g. "push button", "menu item").
Falls back to the PascalCase XML element tag only when the snapshot
lacks a role attribute — which shouldn’t happen for live snapshots,
but can in hand-crafted test XML.
Sourcepub async fn attribute(&self, key: &str) -> Result<Option<String>>
pub async fn attribute(&self, key: &str) -> Result<Option<String>>
Read a single toolkit attribute by key.
Sourcepub async fn attributes(&self) -> Result<HashMap<String, String>>
pub async fn attributes(&self) -> Result<HashMap<String, String>>
All toolkit attributes as a map.
Sourcepub async fn is_showing(&self) -> Result<bool>
pub async fn is_showing(&self) -> Result<bool>
Whether the matched element currently has the Showing state.
Sourcepub async fn is_enabled(&self) -> Result<bool>
pub async fn is_enabled(&self) -> Result<bool>
Whether the matched element is currently interactable.
Returns true when the element has either the AT-SPI Enabled state
or the Sensitive state — GTK reports the latter, Qt/others the
former. Both mean “user can interact with this widget right now.”
Sourcepub async fn text(&self) -> Result<String>
pub async fn text(&self) -> Result<String>
Text contents of the matched element via the AT-SPI Text interface. Unlike other metadata, text isn’t captured in the snapshot — each call makes a live read through the Text proxy after auto-waiting for the element to exist.
Sourcepub async fn click(&self) -> Result<()>
pub async fn click(&self) -> Result<()>
Invoke the primary action (index 0) on the matched element.
Auto-waits for the element to be resolvable, showing, and enabled within the effective timeout. Requires exactly one match.
Sourcepub async fn set_text(&self, text: &str) -> Result<()>
pub async fn set_text(&self, text: &str) -> Result<()>
Replace the contents of an editable text element.
Auto-waits for the element to be resolvable, showing, and enabled.
Sourcepub async fn focus(&self) -> Result<()>
pub async fn focus(&self) -> Result<()>
Give keyboard focus to the matched element.
Auto-waits for the element to be resolvable, showing, and focusable
— the last is a weaker check than “actionable” because some widgets
accept focus without accepting activation (read-only text boxes,
scroll regions, etc.). Uses AT-SPI’s Component::grab_focus under
the hood.
§Toolkit caveats
This relies on the target widget implementing the AT-SPI Component
interface. Some toolkits (notably GTK4 in its current form) don’t
expose Component on all widgets — you may see
Error::Atspi("NotSupported") from grab_focus even when the
widget is visibly focusable on screen. When that happens the
fallback is to drive focus via keyboard navigation (Tab /
Shift+Tab) or synthesize a pointer click.
Sourcepub async fn wait_for_visible(&self) -> Result<()>
pub async fn wait_for_visible(&self) -> Result<()>
Poll until the element exists and has the Showing state. Returns
Ok(()) on success or the last encountered retriable error (or a
Timeout error if the element existed but never became showing).
Poll until the element either doesn’t exist or doesn’t have the
Showing state. The inverse of wait_for_visible.
Sourcepub async fn wait_for_enabled(&self) -> Result<()>
pub async fn wait_for_enabled(&self) -> Result<()>
Poll until the element exists and is interactable (has either the
Enabled or Sensitive state — see Locator::is_enabled for why
both are treated as equivalent).
Sourcepub async fn wait_for_count(&self, n: usize) -> Result<()>
pub async fn wait_for_count(&self, n: usize) -> Result<()>
Poll until the selector matches exactly n elements. Useful for
lists that populate asynchronously after a user action.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Locator
impl !RefUnwindSafe for Locator
impl Send for Locator
impl Sync for Locator
impl Unpin for Locator
impl UnsafeUnpin for Locator
impl !UnwindSafe for Locator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more