[Android] Testing Compose layout
See original GitHub issueThe problem
I haven’t checked well yet, but maybe do we need something in espresso driver? https://developer.android.com/jetpack/compose/testing
Update: Espresso driver https://github.com/appium/appium-espresso-driver is getting compse support. UIA2 driver cannot support it because of technical differences.
Updated
- Espresso driver
- UIA2 driver (via
extra
)
Updated
- UIA2 driver also can find a compose element if the element had testTagsAsResourceId . You can access to the element as
resource-id
.- Appium 1 can access to these elements via XPath https://github.com/appium/appium/issues/15138#issuecomment-1127658653 (since the version autocomplete its package name as valid resource-id rule.)
disableIdLocatorAutocompletion
settings api helps to disable package name autocomplete in case you set an arbitrary name as thetestTagsAsResourceId
, without the package name in compose.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:30
- Comments:64 (24 by maintainers)
Top Results From Across the Web
Testing your Compose layout - Jetpack - Android Developers
Compose provides a set of testing APIs to find elements, verify their attributes and perform user actions. They also include advanced features such...
Read more >Test Your Jetpack Compose Layout - Medium
Use composeTestRule when you need to test a compose layout in an empty activity to freely customize your layout state. And use androidComposeTestRule...
Read more >UI Testing - Jetpack Compose Playground
When you can't find a Composable by a text and you want to make it detectable in your test. Jetpack Compose offers the...
Read more >Getting started with testing Jetpack Compose - Bitrise Blog
Because Jetpack Compose is an instrumentation test, you can use a test framework such as Espresso, but Compose already provides a set of...
Read more >How to test Jetpack Compose UI - Dmytro Shuba
Composable instead of View. · Compose Layout doesn't have IDs and tags. · Different testing tools. · Compose tests are synchronized by default....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Google updated their AccessibilityNodeInfo to include
testTag
in theAccessibilityNodeInfo.extras
object starting in compose UI1.1.0-beta01
. https://android-review.googlesource.com/c/platform/frameworks/support/+/1853077Is this something that can be used to expose
testTag
in UIA2?My company’s QA team is making extensive use of Appium for their automated tests. I recently wrote a few sections of our app using Jetpack Compose, and QA has stated that it has completely broken the tests that deal with UI generated with Compose. They are unable to find any views by using their resource ID or content description. Apparently when I set a content description on a view using
Modifier.semantics{ contentDescription = "my ID" }
, QA is unable to focus in on the exact view. For example, take this piece of code:QA is only able to see this: Note that the content description is on a subview, not on the editText itself. The
layoutId
doesn’t help much, either.Compose just hit its release version yesterday, and as a developer it is so much easier to work with than the declarative XML approach. We need Appium to work with compose since, in my opinion, the benefits to using Compose over XML are far too great. I appreciate the Appium team’s quick attention to this matter 😄