You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detox cannot interact with elements rendered inside React Native's <Modal> component on Android.
React Native's <Modal> creates a separate native Window (Dialog). Detox uses Espresso's onView(matcher).perform(action) without specifying a root matcher, so tap events are dispatched to the main Activity window and never reach the Modal's window.
This means:
element(by.id('button-inside-modal')).tap() silently does nothing (no error, but no effect)
waitFor(element(...)).toBeVisible() may find the element, but tap() fails to trigger onPress
Proposed Solution
Add Espresso's inRoot(isDialog()) support to Detox's Android view interaction layer.
In SingleViewActionPerformer.kt, the current code:
Espresso.onView(matcher).perform(action)
Could be extended to automatically detect and target dialog windows:
// Try default root first, fall back to dialog roottry {
Espresso.onView(matcher).perform(action)
} catch (e:NoMatchingRootException) {
Espresso.onView(matcher).inRoot(RootMatchers.isDialog()).perform(action)
}
Replace <Modal> with <View style={absoluteFill}> — Works but requires modifying production code to accommodate testing limitations.
UIAutomator (adb shell input tap) — input tap coordinates also fail to reach Modal windows on some devices.
System API (Epic [Epic] Extend system interaction support #4464) — The planned UIAutomator-based system.element() API would solve this for system dialogs, but React Native <Modal> is an app-level dialog, not a system dialog. It's unclear if the System API will cover this case.
Problem
Detox cannot interact with elements rendered inside React Native's
<Modal>component on Android.React Native's
<Modal>creates a separate nativeWindow(Dialog). Detox uses Espresso'sonView(matcher).perform(action)without specifying a root matcher, so tap events are dispatched to the main Activity window and never reach the Modal's window.This means:
element(by.id('button-inside-modal')).tap()silently does nothing (no error, but no effect)waitFor(element(...)).toBeVisible()may find the element, buttap()fails to triggeronPressProposed Solution
Add Espresso's
inRoot(isDialog())support to Detox's Android view interaction layer.In
SingleViewActionPerformer.kt, the current code:Espresso.onView(matcher).perform(action)Could be extended to automatically detect and target dialog windows:
Or expose an API for explicit root selection:
Alternatives Considered
Replace
<Modal>with<View style={absoluteFill}>— Works but requires modifying production code to accommodate testing limitations.UIAutomator (
adb shell input tap) —input tapcoordinates also fail to reach Modal windows on some devices.System API (Epic [Epic] Extend system interaction support #4464) — The planned UIAutomator-based
system.element()API would solve this for system dialogs, but React Native<Modal>is an app-level dialog, not a system dialog. It's unclear if the System API will cover this case.Related Issues
RootMatcherssupport (closed as stale, no response from maintainers)Environment
Reproduction