feat(android): add support for multiple-views actions. #4180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances Detox's ability to work with actions on multiple matching views on Android. The aim is to provide greater flexibility for actions, allowing them to handle both single and multiple view scenarios declaratively.
Motivation
As of now, Detox struggles with scenarios where
getAttributes()
is required to operate on several matched elements on Android, even though this is supported on iOS. This PR lays the groundwork to rectify this discrepancy, paving the way for full implementation in a subsequent PR.See: #3196
Problem
perform
method in theEspressoDetox
class relies onViewInteraction
, which doesn't naturally cater to multiple matching views.Solution
To sidestep the challenge posed by
viewInteraction = onView(matcher)
, we transitioned theperform
method inEspressoDetox
to directly useMatcher<View>
instead ofViewInteraction
.This adjustment enable us to iterate on the the matching views by using the by-index functionality of
Matcher
.Furthermore, a new marker interface,
MultipleViewsAction
, has been introduced. Actions having this mark can handle and act upon all views that match.Usage Examples