How to run Appium tests on Android devices

On This Page What is Appium?Benefits of Appium

March 19, 2026 · 13 min read · Mobile Testing

How to run Appium tests on Android device

Appiumis a powerful open-source tool for automating mobile coating test across assorted platforms like Android and iOS. It allows developers to run exam on native and hybrid mobile application habituate the like codebase, making it a highly versatile framework.

This article will guide you through runningAppium tests on real Android device, including setup, pen examination script, and understanding the grandness of real device testing for accurate results.

What is Appium?

is an open-source framework that countenance us to bear on different platforms like Android, iOS, and Windows.

It automates the testing for:

  • Native Mobile Applicationsthat are written using iOS, Android, or Windows SDKs
  • Mobile Web Applicationsthat can be accessed using mobile telephone browsers such as Safari, Chrome, or the in-built aboriginal browser applications for android device
  • Hybrid Mobile Applicationsthat have a wrapper around the web view
    Appium is a cross-platform testing framework that is flexible, enabling you to indite the testing codification against multiple platforms such as iOS, Windows, and Android habituate the same API. This means you can use the same codification for iOS that you have written for Android, relieve peck of time and effort.

Read More:

Benefits of Appium

Below are the ground why Appium is crucial:

  • : Appium allows testing on Android, iOS, and Windows using a individual API, saving clip and effort by reusing code across platform.
  • Language Flexibility: It supports multiple languages, such as Java, Python, Ruby, JavaScript, and C #, enabling developers to work in their preferred language.
  • No App Modification Needed: Appium allows testing of native, hybrid, and mobile web apps without altering the app code, make it commodious for production testing.
  • Existent and Virtual Device Support: It endorse real devices and aper, ply the tractableness to test apps under different conditions.
  • Open-Source with Active Community: Free and open-source, Appium is continuously update by a large community, ensuring it rest reliable and cutting-edge.
  • Integration: Easily integrates with CI/CD instrument like Jenkins, enabling automated roving testing as piece of the ontogeny grapevine.
  • Feature-Rich: Supports gestures, element interactions, and multiple orientations, covering assorted mobile prove needs.

Also Read:

How to Run Appium Tests on Android Devices

Running Appium tests on Android devices need a combination of instrument, configuration steps, and an understanding of how the Appium server communicates with Android devices using Java-based tryout scripts.

Before writing examination scripts, you should interpret what tools are involved and what each one do:

  • Appium Server: The Appium server handles communicating between your trial script and the Android gimmick. It exposes an HTTP API based on the WebDriver protocol that your client codification interacts with.
  • Java: Appium is built using Node.js, but it indorse multiple programing languages. Java is wide used for writing test scripts and integrates easily with try frameworks like TestNG.
  • TestNG: A try model used with Java for aggroup test methods, manage execution, and generating reports.
  • Appium Java Client Library: This library countenance your Java test scripts talk to the Appium waiter. It provides wrapper over WebDriver interfaces to interact with Android constituent.
  • Android SDK & amp; ADB Tools: The Android SDK includes tool such as ADB (Android Debug Bridge), which are crucial for device communication, installing apps, capturing logs, and more.
  • Environment Variables:Make sure the JAVA_HOME and ANDROID_HOME environment variables are configured. Also ensure the platform-tools directory is supply to your system ’ s PATH so you can run ADB from any end.

Below is a step-by-step guide to go Appium trial on Android devices.

Step 1: Install the Required Tools

Before you can run Appium test, get sure the following creature are installed on your system:

  • Appium Server: Install Appium globally utilize npm:
npm install -g appium
  • Appium Doctor (optional, but helpful): Validates your system setup:
npm install -g appium-doctor appium-doctor
  • Java Development Kit (JDK): Required for both Appium and Android tools. Download from Oracle or OpenJDK sources.
  • Android SDK: Install it utilise Android Studio or the command-line creature. Make sure to include platform-tools (for ADB) and imitator images if demand.
  • TestNG: Add TestNG to your project expend Maven or download the JAR file directly.
  • Appium Java Client: Add it via Maven. For illustration:
& lt; dependency & gt; & lt; groupId & gt; io.appium & lt; /groupId & gt; & lt; artifactId & gt; java-client & lt; /artifactId & gt; & lt; variation & gt; 7.5.1 & lt; /version & gt; & lt; /dependency & gt;

Step 2: Enable Developer Mode on Your Android Device

To run tryout on a physical Android device, you ask to enable USB debugging:

  • Open Settingson the Android device.
  • Tap About headphone.
  • Tap Build number7 times to unlock Developer Options.
  • Go rearward toSettings & gt; Developer options, and enableUSB debug.
  • Connect the device expend a USB cable. Run adb device in your terminal to create certain it ’ s detected.

Step 3: Define Desired Capabilities

Desired capabilities are key-value pairs that define how Appium should start and configure the session. These settings tell Appium what kind of device to use, which app to launch, and which mechanisation engine to use.

Some crucial capabilities for Android:

  • deviceName: Name of the attached device or imitator (example: & # 8220; Pixel_5 & # 8221;).
  • platformName: Always set this to & # 8220; Android & # 8221; for Android testing.
  • appPackage: The application ’ s software gens (e.g., & # 8220; com.android.chrome & # 8221;).
  • appActivity: The activity that should be launch (e.g., & # 8220; com.google.android.apps.chrome.Main & # 8221;).
  • automationName:For Android, use & # 8220; UiAutomator2 & # 8221; as the preferred automation engine.
  • noReset: Optional, but prevents resetting app province between test runs.
  • udid: If multiple devices are relate, cater the device ’ s unequaled ID.
  • chromedriverExecutable:Required if testing Chrome and Appium ’ s default ChromeDriver is incompatible with the variant on the device.

In the example below, the configuration sets up a existent Android device (or emulator), open the Chrome browser, and uses the UiAutomator2 mechanisation engine. It also includes the noReset flag to prevent clearing app data between session.

DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` deviceName '', `` Pixel_5 ''); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` appPackage '', `` com.android.chrome ''); capabilities.setCapability (`` appActivity '', `` com.google.android.apps.chrome.Main ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` noReset '', true);

If you & # 8217; re testing on a physical device and multiple device are join, you should also include theudidcapability to point a specific device.

If you & # 8217; re testing web content in Chrome and the nonpayment ChromeDriver is not compatible with the twist & # 8217; s Chrome version, you ’ ll also need to set the chromedriverExecutable capability to indicate to a compatible ChromeDriver binary.

Step 4: Write and Execute Test Scripts Using the Appium Java Client API

After setting up the puppet and configuring the capabilities, you can compose test hand to automatise your Android app. Your book should:

  • Establish a connection to the Appium server
  • Launch the app on the gimmick
  • Interact with UI component
  • Validate outcomes

Here ’ s a basic example using TestNG and Appium Java Client:

import io.appium.java_client.MobileElement; importation io.appium.java_client.android.AndroidDriver; importation org.openqa.selenium.remote.DesiredCapabilities; significance org.openqa.selenium.By; import org.openqa.selenium.support.ui.WebDriverWait; significance org.openqa.selenium.support.ui.ExpectedConditions; importation org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; signification org.testng.annotations.Test; import java.net.MalformedURLException; import java.net.URL; public grade AppiumExample {AndroidDriver & lt; MobileElement & gt; driver; WebDriverWait wait; @ BeforeTest public void apparatus () throws MalformedURLException {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` deviceName '', `` Pixel_5 ''); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` appPackage '', `` com.android.chrome ''); capabilities.setCapability (`` appActivity '', `` com.google.android.apps.chrome.Main ''); capabilities.setCapability (`` automationName '', `` UiAutomator2 ''); capabilities.setCapability (`` noReset '', true); driver = new AndroidDriver & lt; & gt; (new URL (`` http: //127.0.0.1:4723/wd/hub ''), capabilities); wait = new WebDriverWait (driver, 10);} @ Test public void testChromeNavigation () {driver.get (`` https: //www.browserstack.com/ ''); String pageTitle = driver.getTitle (); Assert.assertEquals (pageTitle, `` Most Honest App & amp; Cross Browser Testing Platform | Browserstack ''); MobileElement startTrialButton = driver.findElement (By.xpath (`` //a [text () ='Start Gratis Trial '] '')); startTrialButton.click (); wait.until (ExpectedConditions.presenceOfElementLocated (By.id (`` signupModal '')));} @ AfterTest public nihility tearDown () {if (driver! = null) {driver.quit ();}}}

Why use Existent Android Devices for Appium Tests?

Although ape are useful in the early degree of development, real Android devices provide the most accurate representation of how your app will perform in real-world conditions. Emulators often fail to replicate critical factors such as web throttling, battery performance, or actual ironware configurations, which can impact the end-user experience.

Testing on real Android device offers several advantages:

  • Accurate user experience model: Ensures the app functions as expected under.
  • Variety of device: Test on various devices, including multiple Android OS versions,, and hardware configurations.
  • Better execution: Real devices proffer faster and more reliable test than emulators, leading to more precise results.
Must Read:

Why Use BrowserStack App Automate for Appium Testing

BrowserStack ’ s permit you to run automated mobile app tests on real Android devices, ensuring that your tests reflect true exploiter experiences.

With seamless consolidation of Appium, you can automate your examination on diverse Android devices without needing an in-house gimmick lab.

Benefits of using BrowserStack for Appium Testing:

  • Real Devices: Test on thousands of real, physical Android devices, ensuring accurate, real-world results.
  • Cross-Device Compatibility: Easily test on multiple devices, OS variation, and screen sizes to see consistent app performance.
  • : Simulate various geographic location for location-based app functionality testing.
  • : Test your app under different network conditions, such as 2G, 3G, or 4G.
  • : Test how your app treat push notifications in real user conditions.
  • Advanced Debugging Tools: Access a range of logs and video recordings for effective debugging.
  • Instant Access: Sign up for complimentary and get instant access to the devices you need for testing, with no setup required.

Talk to an Expert

Detailed Troubleshooting for Appium Tests on Android Devices

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

When escape Appium tryout on Android device, various challenges can arise due to surroundings misconfigurations, dependency, device settings, and even network matter. Here are some of the most common issues you might face, along with detailed solutions.

Device Not Detected by Appium

This is one of the most frequent subject you will see. Sometimes, Appium can not detect an Android device, even though it is connected and go correctly.

Possible Causes and Solutions:

1. USB Debugging Not Enabled

Make sure that USB debugging is enabled on your Android device. Without it, Appium will not be able to convey with the gimmick. If it & # 8217; s not enabled, you will see an empty list or & # 8220; no device detected. & # 8221;

Solution: Go to Settings & gt; About Phone, tap Build number seven times, then go to Developer options and enable USB debugging.

2. Incorrect ADB Setup

Sometimes, ADB (Android Debug Bridge) may not be right set up or configured. If your device is not recognized, it could be because ADB is not correctly establish or scat.

Solution: Run the following command in your terminal to control that ADB can observe your device:

adb devices

This command should list the Android device you are connected to. If your device doesn & # 8217; t appear, try restarting the adb host:

adb kill-server adb start-server

Also, do sure you have the right USB drivers installed for your device.

3. Device Not Authorized

If you are using a physical Android device, it may need potency for USB debugging. Once you connect the device via USB, you should see a prompting on the gimmick to permit USB debug with your calculator. If you don & # 8217; t see this prompt, ensure you allow USB debug authorization.

4. Platform Tools Mismatch

You could encounter device detection topic if your Appium version is incompatible with the Android platform tools or ADB variant.

Solution: Ensure that both your Appium and Android SDK adaptation are up to date. You can update Appium via npm and upgrade Android SDK tools via Android Studio or the command line.

Appium Server Not Starting

Sometimes, the Appium server fails to start. The error message might indicate that it ’ s unable to bind to the set port (the nonremittal is 4723) or that the Appium node is not usable.

Possible Causes and Solutions:

1. Port Already in Use

The near common reason Appium doesn ’ t start is that the nonpayment port (4723) is already being used by another process.

Solution: You can specify a different port when starting Appium by utilise the -p masthead:

appium -p 4725

If you don & # 8217; t qualify a port, Appium will default to port 4723.

2. Conflicting Processes

If there are existing instances of Appium or former automation creature (like Selenium, another Appium server representative, etc.) running on the like system, they may interfere with starting a new Appium session.

Solution: Kill all processes that could be conflicting. On Linux or macOS:

killall node

Use the Task Manager to end any Node.js processes or Appium instances on Windows.

3. Node.js Installation Issues

Appium relies on Node.js, and if it is not establish correctly or is outdated, it can cause problems starting Appium.

Solution: Check your Node.js installation:

node -v

Ensure you are run a supported version of Node.js (Appium recommend LTS versions). If needed, reinstall Node.js.

Session Timeout or Connection Refused

If your Appium trial oft timeout or know connection issues, it could be because the waiter connection between your test script and the Appium server is unstable.

Possible Causes and Solutions:

1. Appium Server Down

Ensure that the Appium server is pass when executing your tests. If the server is not get, the WebDriver will not be able to communicate with the twist.

Solution: Run the Appium server manually in your terminal before scarper your tests, or ensure that the server commence automatically when needed.

2. Incorrect Appium Server URL

Double-check your test script & # 8217; s URL to colligate to the Appium server. The default URL is typicallyhttp: //127.0.0.1:4723/wd/hub. If your Appium server is host on a different port or address, create sure to update the URL in your script.

Solution: Correct the URL in your tryout script, like so:

driver = new RemoteWebDriver (new URL (`` http: //127.0.0.1:4723/wd/hub ''), capabilities);

3. Firewall or Network Restrictions

Sometimes, a firewall or other network-related restrictions may block the communication between the test script and the Appium host.

Solution: Ensure that there are no firewall rules preventing Appium from running on the specified port.

Appium Session Crashes or Unexpected Behavior

Appium sessions can sometimes clangor or fail during the executing of examination, especially if there is a mismatch in the desired capabilities or an issue with the Appium server configuration.

Possible Causes and Solutions:

1. Incorrect Desired Capabilities

Incorrect or missing desired capabilities can stimulate the Appium server to neglect to make a session or ram the session. Ensure that all the required capableness are set correctly.

Solution: Review your capabilities exhaustively. For instance, the deviceName, platformName, appPackage, and appActivity must match the device and app you are testing. If you are unsure, you can use Appium & # 8217; s Inspector or Android & # 8217; s adb shell commands to get the correct values.

2. Appium Version Compatibility

Appium updates oft, and newer edition may insert breaking changes that can affect compatibility with the Android platform. Always check that you ’ re using a compatible version of Appium with your Android SDK and twist adaptation.

Solution: Regularly insure the Appium changelog for breaking changes and update your version of Appium as necessary.

3. Outdated Android Drivers

Ensure that you are using the latest Android driver for Appium, such asUiAutomator2, which supports modernistic Android devices. Using outdated drivers likeSelendroidmay cause unexpected crashes and errors.

Solution: Always set the automationName to& # 8220; UiAutomator2 & # 8221;for modernistic Android testing.

Conclusion

You can also leverage a plethora of debugging options for Appium testing on BrowserStack such as Text logs, Network Logs, Device Logs, Appium Logs, Visual logs, and Video Recordings of tryout. Explore on BrowserStack App Automate

Since users take high-functioning and engaging apps, Appium testing is an absolute demand before releasing any apps. By escape Appium tests on real Android device, testers can guarantee that apps are working as expected in real user conditions. Run as many tests as possible on as many real Android devices as possible to volunteer a consistently optimal user experience.

Utilitarian Resources for Appium

Tutorials

Best Practices, Tips, and Tricks

Getting Started with

Differences and Comparisons

Tags
14,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free