# 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: [Stories by Julien Salvi on Medium](<https://devfeed.tech/sources/stories-by-julien-salvi-on-medium.md>)

Topics: [ui-testing](<https://devfeed.tech/topics/ui-testing.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Android](<https://devfeed.tech/topics/android.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [appium](<https://devfeed.tech/tags/appium.md>), [compose](<https://devfeed.tech/tags/compose.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [ui-testing](<https://devfeed.tech/tags/ui-testing.md>), [uiautomator](<https://devfeed.tech/tags/uiautomator.md>)

## AI overview

This tutorial explains how Aircall adapted Android UI automation tests when migrating from View-based components to Jetpack Compose. It describes using Compose semantics and testTag values mapped to resource IDs, then locating the resulting components with UiSelector in Appium and UIAutomator.

## 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