Skip to content
You're viewing the v2 docs. Looking for v1?Go to v1 docs
Docs
Testsigma
Popular questions
↑↓ to navigate↵ to selectesc to close
Book a demo

Create an Android test case

An Android test case runs against an .apk build on a real device or an emulator. There are 4 ways to build one, and they differ in what you start from.

RouteStart fromBest when
NLPsNothingYou know the flow and want exact control
RecorderThe application on a streamed deviceThe flow is quicker to perform than to describe
CopilotThe application on a streamed deviceYou want Copilot to draft steps as you record
AttoRequirements, designs, or promptsYou are covering a feature rather than one flow

Before you start, you need a project and an Android application, the .apk itself, and a device or emulator available as a Test Machine. Recording on a local device also needs Testsigma Terminal installed.

  1. Go to Create Tests > Test Cases.

  2. Expand a folder in Test Case Explorer and click the + icon next to a subfolder.

  3. Confirm the folder and subfolder, enter a name, and click Create.

The first step is created for you as Launch App, since a mobile test has to open the application before it can act on it.

  1. Click Add New Step on the Test Case Details page.
  2. Select the NLP for the action you want, then supply its test data and elements.
  3. Repeat until the flow is complete.

Android NLPs use Tap on rather than Click on, since the interaction is a tap. See Create test cases for the full action list and the step types.

Recording streams a device from a Test Lab, so the recorder carries controls the web recorder has no need for.

  • Device controls: Install App, Mirroring mode, Inspect Mode, which shows element attributes without recording a step, Swipe By Coordinates, Tap By Coordinates, Search Element, Go back, Home, Hide Keyboard, and Rotate Screen
  • Element actions: Tap, Enter Data, View Code, Clear, and Element Details

The mobile recorder, with the streamed device, the device controls, and the element actions

Android supports 5 locator types, in this order of preference:

  • Accessibility ID: the first choice. The same value carries across Android and iOS, which makes a test easier to port, and it is the least likely to change when the source is restructured
  • ID: the second choice. Every element is supposed to have a unique one
  • XPATH: parses the source to reach the element
  • Class Name: the value of the element’s Class Name attribute
  • Name: the value of the element’s Name attribute

Inspect Mode in the recorder, listing the selected element's attributes

See Elements for capturing, editing, and importing them.

A blank screen with no selectable elements usually means a hybrid application rendering a WebView.

Refresh the page first. If the screen is still blank, click H in the recorder panel and select the WebView to switch context. Each switch is recorded as its own step:

  • Switch to Webview context when you enter the WebView
  • Switch to Native App Context when you return to the native application
  • Switch to context with name WEBVIEW_6890.1 when you pick a named view

Select WebView in the recorder, listing the WebView contexts available on the screen

Testsigma needs 2 details to locate an Android application and the page to test: the App Package Name, which identifies the app, and the App Activity Name, which identifies the screen. An activity is to an Android app what a page is to a website.

Android SDK has to be installed and set up on the machine.

  1. Connect the device or emulator, and open the app you want to inspect.

  2. Run adb devices in a terminal to confirm the device is listed.

  3. Read the currently focused app:

    • macOS and Linux: adb shell dumpsys window | grep -E 'mCurrentFocus'
    • Windows: adb shell dumpsys window | find "mCurrentFocus"
  4. The output gives both values. For WhatsApp, com.whatsapp is the package name and com.whatsapp.HomeActivity is the activity name.

A test case can install a particular build rather than the latest one, which is how you test across app versions.

  1. Go to Test Data > Uploads, click the ellipsis icon ⋮ against the uploaded file, and click Upload New Version.

  2. Click Browse File, upload the new build, and set its name and version.

  3. In the test case, add the Install the app name app-name and version app-version NLP.

  4. Click app-name and select the build, then click app-version and select the version.

  5. Click Create Step.

Why do local runs on a real device fail with a permission error?

Section titled “Why do local runs on a real device fail with a permission error?”

Device-level settings are off by default, and which ones differ by brand.

  • Realme and Oppo: turn on Developer Options, USB Debugging, and Disable Permission Monitoring
  • OnePlus: the same 3, plus configure or disable battery optimization for the app under test
  • Xiaomi: turn on Developer Options, USB Debugging, and USB Debugging (Security Settings), and turn off MIUI Optimization

The NLP acts only on an element already rendered in the current viewport. When the element exists in the app but has not scrolled into view, the step has no target.

Yes. Start the emulator first, then the Testsigma agent, then select Local Devices and confirm the emulator appears under Test Machine. An emulator started after the agent is not detected.

Why does app data reset when I restart the app mid-session?

Section titled “Why does app data reset when I restart the app mid-session?”

Closing and relaunching an Android app in the same session resets its data, which iOS does not do. The difference comes from the automation capabilities of the two platforms. The fix is a desired capability set in Test Environment Settings. See Desired capabilities.

Why does the mobile test recorder fail to start?

Section titled “Why does the mobile test recorder fail to start?”

Check the recorder’s logs first, since they name the actual cause. A common one on Android is the activity name in the manifest not matching the real splash screen activity, so the recorder launches the wrong screen. Find the real one with ADB, as in Find the app package and activity.

Why are my resource IDs breaking in other environments?

Section titled “Why are my resource IDs breaking in other environments?”

The package name in a resource ID changes between builds. Store only the <id_value> portion and let Testsigma append the package name of the selected app.

Was this page helpful?