I'm trying to interact with a SeekBar
control in an Espresso test. Specifically, I'd like to click at the location of a "node", where a node is a location that the draggable thumb can snap to.
The UI tree has no knowledge of the SeekBar
internals. It doesn't seem possible to use Espresso to target one of the nodes directly; all it sees is a SeekBar
.
Instead, I wonder if I could use the Accessibility tree that exists for TalkBack support. The uiautomatorviewer
tool confirms that this tree contains a virtual view for each node. Each virtual view has a content description.
My goal is to get a hold on one of these virtual views in a matcher and perform a click
on it. Something like...
onVirtualView(withContentDescription("banana")).perform(click());
where onVirtualView
would be similar to onView
. I don't know how to programmatically access this Accessibility tree and if it's possible to trigger actions on it. Can someone shed light on the feasibility of this technique?
I'm aware of the approach that sets the progress value (Espresso - Set SeekBar). I'm trying to avoid that method as I want the test to be flexible to changes to the number in the number of slots.