[Android][Compose][Appium] Take a look at AndroidComposeTestRule

Composer has ComposeTestRule and AndroidComposeTestRule to test Composer.

https://developer.android.com/jetpack/compose/testing

As Appium, we’d like to inject them to interact with composer components reliably. So, I took a look at their code a bit to understand the codebase.

According to https://developer.android.com/jetpack/compose/testing#espresso-interop this section, the composer rule can use with Espresso. Thus, I guessed Appium-Espresso driver also could access composer components over the rule.

The key area was https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule.android.kt;l=113-118?q=AndroidComposeTestRu&ss=androidx.

The code had createAndroidComposeRule. The rule got ActivityScenarioRule. I could see some methods such as get element nodes, the root or actions. One interesting thing was AndroidTestOwner. Was this main controller for Android Test? (Just a guess). It seemed ComposeRootRegistry worked to get composer components via composeRootRegistry.getRegisteredComposeRoots() in getRoots in AndroidTestOwner.

As another way to work with Android composer via Appium, I assume Appium can interact with elements via accessibility features. Composer has below resource/accessibility features. contentDescription and resource id are typical ways to interact elements via UIA2. So, it would be great if Appium can work with composer via them at least…

https://developer.android.com/jetpack/compose/resources
https://developer.android.com/jetpack/compose/accessibility

Update:

1 Comment

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.