Quasa
Use QUASA App
Join the pioneer of Web3 crypto freelancing today!
Open
Technology

8 Tips and Tricks for Appium Android Tests

|Author: Viacheslav Vasipenok|5 min read| 2055
8 Tips and Tricks for Appium Android Tests

Hello!

Appium is an open-source, cross-platform tool designed to automate native, mobile web, and hybrid applications. It performs reliably on both native and hybrid apps. Companies that build their applications using the iOS or Android SDK can integrate Appium seamlessly. In addition, Appium automation enables efficient testing of mobile web apps accessed through mobile browsers.

8 Tips and Tricks for Appium Android TestsBecause many hybrid apps rely on WebView, Appium offers several standout capabilities that set it apart from other testing solutions.

Flexibility Across Platforms

Beyond its power and ease of use, one of Appium’s greatest strengths is its flexibility. Test cases can run on any device without requiring code modifications for different platforms, which greatly simplifies the testing process. As free software for mobile app testing, Appium helps both newcomers and experienced testers automate applications on iOS and Android with minimal effort.

Verify That The Android Application Is Preinstalled

Developers frequently need to verify whether their Android app is already installed on a device. A common reason is to access features available only to logged-in users, such as testing a login flow. Since logging in at the start of every test case is time-consuming, checking the installation status in advance helps optimize execution time.

Enabling The Mouse Pointer Location On Android

The mouse pointer remains hidden in Android Device Monitor during UI element locator capture. To make the pointer visible, enable Pointer Location in Developer Options.

8 Tips and Tricks for Appium Android TestsWhen running Appium tests, it is often necessary to see exactly where the pointer or touch occurs on the device. This information allows testers to debug interactions and confirm that taps and clicks are performed at the intended locations.

Appium provides methods to retrieve pointer coordinates, which can then be used for precise debugging. Tracking pointer location helps identify why actions such as swipes, taps, or scrolls fail—most often because the target element is not displayed or is currently invisible.

Process For Capturing Screenshots On Test Failure

Appium can capture screenshots of the current screen, a feature especially useful for debugging failed tests. When a test passes in the console but the simulator or emulator shows incorrect behavior, screenshots reveal what actually occurred during execution. On failure, Appium automatically captures and saves the screenshot, typically to the report folder, allowing quick visual analysis of the issue.

Dismissing Alerts On Android With Appium

8 Tips and Tricks for Appium Android TestsAppium offers two approaches for handling system dialogs and pop-ups: manual and automatic.

In automatic mode, set the appropriate desired capabilities so Appium accepts or dismisses alerts without additional code. In manual mode, locate the allow or deny button using its locator and perform a click action.

Appium Can Handle The System Dialogs/alerts In 2 Ways:

  1. Manually: locate the allow/deny button of the element and perform a click() action.
  2. Automatically: set desired capabilities to auto-accept or auto-dismiss alerts and dialogs.

Setting the Capabilities:

  • Set the capability autoAcceptAlerts to true to accept alerts automatically.
  • Set the capability autoDismissAlerts to true to dismiss alerts automatically.

You Can Use The Following Code To Dismiss Dialogs Automatically:

8 Tips and Tricks for Appium Android TestsDesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability(“autoAcceptAlerts”, true);//it will automatically accept the alerts

cap.setCapability(“autoDismissAlerts”, true);//it will automatically dismiss the alerts

Push Notifications And Notification Management

Push notifications are a common feature in mobile applications and can be handled easily with Appium. Android allows developers to configure push notifications, and Appium provides straightforward methods to test them.

A push notification appears as a message on the device. Appium’s openNotifications() method opens the notification shade. The title and body of each notification can be retrieved using locators such as android:id/title and android:id/text. Notifications can be dismissed by tapping or by using the backgroundApp(seconds) method to send the app to the background temporarily.

8 Tips and Tricks for Appium Android TestsWhen openNotifications() is called, Appium displays the list of received push notifications along with their titles, content, and relevant icons.

Failing Test Cases Faster

Appium’s newCommandTimeout capability lets you specify how long (in seconds) the server should wait for a new command before ending the session. Setting a lower value helps tests fail quickly when an element cannot be found or an exception occurs, preventing indefinite hangs during debugging or long-running sessions on emulators and simulators.

8 Tips and Tricks for Appium Android TestsThis approach is particularly valuable in 2026 when teams run extensive automated suites and need rapid feedback on failing tests.

Writing Test Cases At A Speedier Pace

To accelerate test creation while maintaining quality, follow these practical recommendations:

8 Tips and Tricks for Appium Android Tests

  1. Use a local Appium server and physically connected real device for fastest execution; reserve cloud devices for broader regression coverage.
  2. Extract all UI element locators in a single pass using Appium Inspector or a similar tool, recording IDs, text values, and class names upfront.
  3. Prefer unique IDs for UI elements; when unavailable, use stable names or class attributes. XPath should be a last resort and kept free of index-based selectors whenever possible.

8 Tips and Tricks for Appium Android TestsCollaborating with developers early helps ensure locators remain reliable as the application evolves.

Changing Context Types During Testing

When testing Android applications that mix native and WebView screens, context switching is required. Native screens use the NATIVE_APP context, while WebView screens use the WEBVIEW context.

Viewing The Available Contexts

The getContextHandles() method returns a set of all available contexts. Example:

Set<String> contexts = driver.getContextHandles();
for (String context : contexts) { System.out.println(context); }

Typical output: [“NATIVE_APP”, “WEBVIEW_1”]

Switching Between Contexts

8 Tips and Tricks for Appium Android TestsOnce the desired context is identified, switch using:

driver.context(“WEBVIEW_1”);
String webviewTitle = driver.getTitle();
System.out.println(“Web View Title: “+webviewTitle);
assertEquals(“Payments”, webviewTitle);

Automate your mobile app testing on real devices. LambdaTest connects your apps to the cloud and provides access to thousands of real devices and mobile emulators online.

LambdaTest Appium Cloud enables testing of native, hybrid, and web apps across 3000+ real device and OS combinations.

Other features of LambdaTest App automation platform:

  • Parallel testing to accelerate execution, obtain early feedback on commits, and reduce the cost of late-stage defect discovery.
  • Detailed test logs for real-time debugging.
  • Native integrations with Jenkins, CircleCI, Travis CI, and other continuous-integration tools.

Thank you!
Join us on social media!
See you!

Share:

Subscribe to our newsletter

Get the latest Web3, AI, and crypto news delivered straight to your inbox.

0