# UI tests with Jetpack Compose and Appium x UIAutomator

DevFeed: [UI tests with Jetpack Compose and Appium x UIAutomator](<https://devfeed.tech/articles/ui-tests-with-jetpack-compose-and-appium-x-uiautomator-25941.md>)

Original publisher: [Read original article](<https://juliensalvi.medium.com/ui-tests-with-jetpack-compose-and-appium-x-uiautomator-5d276fb655aa?source=rss-cbfc736ddcd3------2>)

Author: Julien Salvi

Published: 2022-12-05T13:01:16Z

Content type: tutorial

Language: en

Sources: [Julien Salvi](<https://devfeed.tech/sources/stories-by-julien-salvi-on-medium.md>)

Topics: [ui-testing](<https://devfeed.tech/topics/ui-testing.md>), [UiAutomator](<https://devfeed.tech/topics/uiautomator.md>), [Test automation](<https://devfeed.tech/topics/test-automation.md>), [Android Testing](<https://devfeed.tech/topics/android-testing.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>)

Tags: [aircall](<https://devfeed.tech/tags/aircall.md>), [android](<https://devfeed.tech/tags/android.md>), [annotation](<https://devfeed.tech/tags/annotation.md>), [api](<https://devfeed.tech/tags/api.md>), [appium](<https://devfeed.tech/tags/appium.md>), [automation](<https://devfeed.tech/tags/automation.md>), [compose](<https://devfeed.tech/tags/compose.md>), [framework](<https://devfeed.tech/tags/framework.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [migration](<https://devfeed.tech/tags/migration.md>), [production](<https://devfeed.tech/tags/production.md>), [qa](<https://devfeed.tech/tags/qa.md>), [quality](<https://devfeed.tech/tags/quality.md>), [semantics](<https://devfeed.tech/tags/semantics.md>), [tag](<https://devfeed.tech/tags/tag.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [ui](<https://devfeed.tech/tags/ui.md>), [ui-testing](<https://devfeed.tech/tags/ui-testing.md>), [uiautomator](<https://devfeed.tech/tags/uiautomator.md>)

## AI overview

Aircall's existing Appium and UIAutomator tests located Views by resource ID, but could not find Compose components by their tags. To support the migration, add a semantics testTag to each Composable, enable testTagsAsResourceId at the top-level Composable, and change @AndroidFindBy to use a UiSelector with the component ID. UIAutomator's UiSelector can also locate elements by text or class name. The article says this approach let the team keep existing component IDs and avoid major QA-side rewrites; it reports validating the move to Compose, not broader results beyond Aircall's setup.

## Source excerpt

At Aircall we are pushing a lot around quality thanks to our great QA team. Huge efforts are put on Android developer side with the unit tests and our QA engineers tackle everything around automation & UI tests. Before integrating our brand new design system made with Compose UI in production, we wanted to be sure that the transition to Compose would be painless with our automation framework and tools: Appium and UIAutomator. This article will explain how the Android team validated the move to Compose with our automation framework. Automation tests with View components The Aircall QA team has developed lots of automation tests that cover more than 90% of the use cases in the Android app. And to do so, they rely on Appium with the UI testing framework UIAutomator which is an instrumentation-based API and works with the AndroidJUnitRunner test runner. To locate a View-based component in the application, UIAutomator provides an annotation @AndroidFindBy where you need to specify the resource id of a UI element you want to identify. @AndroidFindBy(id = "myButtonId") protected WebElement myButton; But this method does work properly with Compose UI components. Indeed, when looking for a Composable with its dedicated tag, no elements are found in the screen. Now, let's have a closer look at the changes we had to make in order to smoothly add our new Compose code in the current codebase and not breaking everything on the automation side. UI tests with Compose UI and UIAutomator To unlock the UI testing with UIAutomator and Compose, we will have to take advantage of the semantics Modifier in each Composable we want to locate with the testTag property. In order to ease the migration, we are going to keep the same component IDs we were using with our View-based elements. Modifier.semantics { testTag = "myButtonId" } And at the top level Composable, we should toggle the configuration to map testTags to the resource IDs in the semantics Modifier. This will allow the automation f