If you use UI-Automator with AndroidX, you can find the dialog box and buttons.
This is the gradle dependency code.
dependencies { androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' }
You can access the ALLOW button with this code.
This is the Kotlin code.
val button = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) .findObject( UiSelector().text( activityTestRule .activity .getString(R.string.allow_button) .toUpperCase() ) ) if (button.exists() && button.isEnabled) { button.click() }
hyung jun yoo
source share