{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SelectorsKt

public final class SelectorsKt


Summary

Public methods

static final @NonNull SemanticsNodeInteractionCollection

Returns all the nodes matching the given matcher.

static final @NonNull SemanticsNodeInteraction

Expects to return exactly one node matching the given matcher.

static final @NonNull SemanticsNodeInteractionCollection

Returns all the ancestors of this node.

static final @NonNull SemanticsNodeInteraction

Returns exactly one child of this node.

static final @NonNull SemanticsNodeInteraction
onChildAt(@NonNull SemanticsNodeInteraction receiver, int index)

Returns child of this node at the given index.

static final @NonNull SemanticsNodeInteractionCollection

Returns children of this node.

static final @NonNull SemanticsNodeInteraction

Returns the first node in this collection.

static final @NonNull SemanticsNodeInteraction

Returns the last node in this collection.

static final @NonNull SemanticsNodeInteraction

Returns a parent of this node.

static final @NonNull SemanticsNodeInteraction

Returns exactly one sibling of this node.

static final @NonNull SemanticsNodeInteractionCollection

Returns all siblings of this node.

Public methods

filter

public static final @NonNull SemanticsNodeInteractionCollection filter(
    @NonNull SemanticsNodeInteractionCollection receiver,
    @NonNull SemanticsMatcher matcher
)

Returns all the nodes matching the given matcher.

Parameters
@NonNull SemanticsMatcher matcher

Matcher to use for the filtering.

filterToOne

public static final @NonNull SemanticsNodeInteraction filterToOne(
    @NonNull SemanticsNodeInteractionCollection receiver,
    @NonNull SemanticsMatcher matcher
)

Expects to return exactly one node matching the given matcher.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if no element is found.

Parameters
@NonNull SemanticsMatcher matcher

Matcher to use for the filtering.

onAncestors

public static final @NonNull SemanticsNodeInteractionCollection onAncestors(@NonNull SemanticsNodeInteraction receiver)

Returns all the ancestors of this node.

Example: For the following tree

|-A
|-B
|-C <- this node
Returns B, A

onChild

public static final @NonNull SemanticsNodeInteraction onChild(@NonNull SemanticsNodeInteraction receiver)

Returns exactly one child of this node.

Use this only if this node has exactly one child.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if none or more than one element is found.

onChildAt

public static final @NonNull SemanticsNodeInteraction onChildAt(@NonNull SemanticsNodeInteraction receiver, int index)

Returns child of this node at the given index.

This is just a shortcut for "childrenindex".

onChildren

public static final @NonNull SemanticsNodeInteractionCollection onChildren(@NonNull SemanticsNodeInteraction receiver)

Returns children of this node.

onFirst

public static final @NonNull SemanticsNodeInteraction onFirst(@NonNull SemanticsNodeInteractionCollection receiver)

Returns the first node in this collection.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if no element is found.

onLast

public static final @NonNull SemanticsNodeInteraction onLast(@NonNull SemanticsNodeInteractionCollection receiver)

Returns the last node in this collection.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if no element is found.

onParent

public static final @NonNull SemanticsNodeInteraction onParent(@NonNull SemanticsNodeInteraction receiver)

Returns a parent of this node.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if none or more than one element is found.

onSibling

public static final @NonNull SemanticsNodeInteraction onSibling(@NonNull SemanticsNodeInteraction receiver)

Returns exactly one sibling of this node.

Use this only if this node has exactly one sibling.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if none or more than one element is found.

onSiblings

public static final @NonNull SemanticsNodeInteractionCollection onSiblings(@NonNull SemanticsNodeInteraction receiver)

Returns all siblings of this node.

Example: For the following tree

|-A
|-B1
|-B2 <- this node
|-B3
Returns B1, B3