Most developers think setting up Appium with Java is like adding any other dependency—update your pom.xml and start writing tests.
In reality, that Maven dependency is just one piece of a multi-layered setup. I’ve watched experienced Java developers hit walls they’ve never seen. Appium Server won’t connect, desired capabilities fail, or the app won’t launch.
However, Appium is server-based architecture, not a self-contained Java library like JUnit or TestNG. This means a client dependency alone is insufficient. The Appium server, platform drivers, and the device layer must be available, configured, and valid for the test execution to proceed.
In this article, I will explain how Appium operates behind the Java client, outline the components involved in setup, and show the path to stable execution.
What is Appium
Appium is an open-source automation tool used for testing mobile apps and mobile browsers. Appium lets tests interact with real devices and emulators the same way a user does. It sends commands to the app through the device’s automation framework and verifies behavior.
What can it automate?
Appium supports:
- Native apps (built for iOS or Android)
- Hybrid apps (web view + native UI)
- Mobile web browsers (Safari, Chrome, Firefox)
Key Features of Appium
Appium lets teams test efficiently, simulate real user interactions, and scale automation without modifying the app.
Here are the core features of Appium:
- Cross-Platform Test Automation: Automates tests on both Android and iOS, including real devices, emulators, and simulators.
- WebDriver-Based: Uses the W3C WebDriver protocol, making it compatible with Selenium and familiar to testers.
- Supports Multiple App Types: Works with native, hybrid, and mobile web apps using a single framework.
- Gesture Automation: Enables user interactions like tap, swipe, drag, pinch, and zoom on touchscreens.
- Multi-Language Support: Test scripts can be written in Java, Python, JavaScript, C#, Ruby, and more.
- Open-Source and Extensible: Free, community-driven, and supports plugins for enhanced capabilities.
- Distributed and Parallel Testing: Run tests simultaneously across multiple devices to speed up execution.
How Does Appium Work?
Appium works as a server-client architecture that communicates with mobile devices to execute automated tests. Test scripts send commands to the Appium server, which then interacts with the device or emulator to perform actions on the app, just like a real user would.
Step-by-step process:
- Test Script Sends Commands: The tester writes scripts in a supported language (Java, Python, JS, etc.), using WebDriver commands to define actions and validations.
- Appium Server Receives Requests: The Appium server acts as a bridge between the test script and the device.
- Device Interaction: The server translates commands into device-specific actions using automation frameworks like UIAutomator2 for Android or XCUITest for iOS.
- Action Execution: The app responds to gestures and commands such as tap, swipe, scroll, type, or retrieve element data.
- Results Returned: Appium sends the response back to the test script, confirming whether the action passed or failed.
Introduction to Java
Java is one of the best programming languages. It is extremely popular in the market because of its impressive features. Java is a robust, high-level, object-oriented, and secure programming language. It is used to develop mobile apps, web apps, desktop apps, games, and much more.
Java is used for:
- Designing web applications and creating Android applications.
- Developing software tools too
- Game development
- Writing various automation test scripts
Appium Automation with Java: Why Use it in 2026?
Appium is designed to automate mobile apps without modifying them, and Java provides a robust programming environment for building scalable, maintainable tests. Together, they offer a combination of reliability, flexibility, and cross-platform capability that few other setups match.
This is why testers use Appium with Java in 2026:
- Unified Cross-Platform Tests: Appium translates WebDriver commands into native device instructions using UIAutomator2 (Android) or XCUITest (iOS). Java allows writing one test script that interacts with multiple platforms, reducing duplication while maintaining platform-specific precision.
Also Read: How to approach Cross Platform Testing
- Robust Object-Oriented Structure: Java enables testers to implement Page Object Models, design patterns, and reusable functions, making complex mobile workflows easier to manage and maintain. For example, a single page object can encapsulate both Android and iOS UI elements with minimal duplication.
Read More: Page Object Model and Page Factory in Appium
- Advanced Exception Handling: Mobile automation often encounters transient issues like element not found, slow network responses, or device lag. Java’s structured exception handling allows retry mechanisms, custom waits, and logging, giving tests resilience against flakiness.
Also Read: How to use wait() in Java?
- Extensive Libraries and Framework Support: Java integrates seamlessly with TestNG, JUnit, Apache POI, and logging frameworks. This allows data-driven testing, parallel execution, detailed reporting, and CI/CD integration for large-scale test suites.
- Parallel Execution and Scalability: Using Java with Appium, tests can run on multiple devices or emulators simultaneously via TestNG or Maven, enabling large regression suites to complete faster.
Prerequisites For Running Appium with Java in 2026
Setting up Appium with Java requires a properly configured development environment, connected devices, and the necessary libraries and drivers.
Essential prerequisites:
- Java Development Kit (JDK): Install the latest JDK (version 8 or above). Ensure JAVA_HOME is set in system environment variables so Appium and your IDE can locate Java.
- Integrated Development Environment (IDE): A Java IDE like IntelliJ IDEA or Eclipse is recommended for writing, running, and debugging test scripts.
- Appium Server: Install Appium via Node.js NPM or use the Appium Desktop app for a GUI-based server. Ensure the server can connect to devices or emulators.
- Appium Java Client Library: Add the Appium Java client dependency to your project (via Maven or Gradle). This library allows Java scripts to communicate with the Appium server.
- Android Setup:
- Install Android Studio and SDK tools.
- Set ANDROID_HOME in environment variables.
- Ensure at least one emulator or a connected real device is available for testing.
- iOS Setup (for Mac users):
- Install Xcode and command-line tools.
- Enable WebDriverAgent for automation on iOS devices.
- Have an iOS simulator or real device connected.
- Device Drivers: Install necessary USB or platform-specific drivers to ensure the host machine can communicate with real devices.
- Build Tools (Optional but Recommended): Tools like Maven or Gradle help manage dependencies and automate build/test execution.
- Browser Drivers (for mobile web testing): Install ChromeDriver for Android and SafariDriver for iOS to enable browser automation.
Running Your First Appium-Java Test in 2026
Now that you have set up all prerequisites, you can create and execute your first Appium test using Java.
Running your first Appium-Java test involves creating a project, connecting a device, starting the Appium server, writing a simple script, and executing it to confirm that automation works end-to-end.
Step-by-step process:
1. Create a Java Project: Open your IDE (IntelliJ or Eclipse) and create a Maven or Gradle project. Add the Appium Java client and Selenium WebDriver dependencies.
2. Connect a Device:
- For Android, ensure a real device is connected via USB
- For iOS, launch a simulator or connect a real device.
3. Start the Appium Server:
- Run Appium Desktop or start it via CLI using appium.
- Verify that the server is running on the default port (usually 4723).
4. Write Your First Test Script:
- Initialize the DesiredCapabilities to specify platform, device, and app details.
- Instantiate the AndroidDriver or IOSDriver with the Appium server URL.
- Use driver commands to perform actions like opening the app, tapping a button, or retrieving text from an element.
Example snippet (Android):
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "Android");
caps.setCapability("deviceName", "Pixel_3");
caps.setCapability("app", "/path/to/app.apk");
AndroidDriver<MobileElement> driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), caps);
MobileElement element = driver.findElement(By.id("com.example:id/button"));
element.click();
driver.quit();5. Run the Test: Execute the script from your IDE or via Maven/Gradle. Appium will launch the app on the device or emulator and perform the actions defined in the script.
6. Verify Results: Observe the app behavior on the device. If the test passes and performs the expected actions, your setup is complete.
Why Run Appium Java Tests on Real Devices
Running Appium Java tests on real devices ensures that mobile apps are validated under real-world conditions. Unlike emulators or simulators, real devices accurately reflect performance, touch responsiveness, screen resolution, and hardware-specific behavior, providing a true picture of the user experience.
Testing on real devices also allows for handling network variability, OS fragmentation, and sensor interactions like GPS or camera functionality. This reduces flaky tests, catches issues that emulators might miss, and ensures apps perform reliably across different devices before release.
Tools like BrowserStack provide access to thousands of Android and iOS devices, enable running tests in parallel, and offer detailed logs and screenshots for debugging. BrowserStack’s cloud infrastructure removes the need to maintain physical devices and simplifies managing multiple device configurations.
Automating Appium tests using Java with Browserstack App Automate
BrowserStack App Automate lets you test native and hybrid mobile applications using the Appium automation framework on thousands of real Android and iOS devices. It’s often very easy to run Appium tests written in Java on real Android and iOS devices on BrowserStack.
Note: If you are new to BrowserStack, refer to this document on executing your first Appium test case on the BrowserStack cloud. Run Appium tests with Java
Setup
You will need to have a BrowserStack username and access key. Get your access credentials by signing up for a free trial or purchasing a plan. After that, launch Browserstack App Automate.
It is necessary to have Appium’s Java client library installed. If you do not have one, please add the Maven dependency below to your project in IDE. In this case, the IDE being used is Eclipse.
// Maven users can add this dependency to project's POM <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>7.0.0</version> </dependency>
Also, ensure that you have access to an Android app (.apk or .aab file) or an iOS app (.ipa file)
/* Note the "app_url" value for the sample app. This value uniquely identifies the app on BrowserStack. */
{"app_url":"bs://c700ce60cf13ae8ed97705a55b8e022f13c5827c"}
/* In your test script, use this "app_url" value to specify the application under test using the "app" capability. During test execution, the sample app will automatically be installed and launched on the device being tested. */
caps.setCapability("app", "bs://c700ce60cf13ae8ed97705a55b8e022f13c5827c")If you do not have an application, please use the sample android or iOS app. In this case, let’s use an Android application.

As a next step, configure the code, as shown in the screenshot below. In this case, let’s select a real Google Nexus 6 device with Android from the drop-down as shown below.
You can also copy the code snippet from the App Automate dashboard to execute the test case.
Execution

package android;
import java.net.URL;
import java.util.List;
import java.util.function.Function;
import java.net.MalformedURLException;
import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class BrowserStackSample {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities caps = new DesiredCapabilities();
// Set your access credentials
caps.setCapability("browserstack.user", "your_username");
caps.setCapability("browserstack.key", "your_key");
// Set URL of the application under test
caps.setCapability("app", "bs://c700ce60cf13ae8ed97705a55b8e022f13c5827c");
// Specify device and os_version for testing
caps.setCapability("device", "Google Nexus 6");
caps.setCapability("os_version", "5.0");
// Set other BrowserStack capabilities
caps.setCapability("project", "First Java Project");
caps.setCapability("build", "browserstack-build-1");
caps.setCapability("name", "first_test");
// Initialise the remote Webdriver using BrowserStack remote URL
// and desired capabilities defined above
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(
new URL("http://hub.browserstack.com/wd/hub"), caps);
// Test case for the BrowserStack sample Android app.
// If you have uploaded your app, update the test case here.
AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(
MobileBy.AccessibilityId("Search Wikipedia")));
searchElement.click();
AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(
MobileBy.id("Google")));
insertTextElement.sendKeys("BrowserStack");
Thread.sleep(5000);
List<AndroidElement> allProductsName = driver.findElementsByClassName(
"android.widget.TextView");
assert(allProductsName.size() > 0);
// Invoke driver.quit() after the test is done to indicate that the test is completed.
driver.quit();
}
}Now, execute the first Appium test on BrowserStack. Open the terminal/command prompt and navigate to the folder containing your test script on your local machine. Build and run the test script like any other Java program using your project’s preferred build tools such as Maven and Gradle.
# Using Maven mvn test -P <android-first-test> or mvn compile exec:java -Dexec.mainClass="android.BrowserStackSample"
After executing the test case, view the results on the BrowserStack dashboard. That’s how it works.
Conclusion
Appium with Java provides a powerful, flexible framework for automating mobile app testing across Android and iOS. By enabling cross-platform, gesture-driven, and scalable tests, it ensures apps behave reliably in real-world conditions, reduces flaky tests, and improves overall testing efficiency.
Platforms like BrowserStack simplify running Appium Java tests by giving instant access to thousands of real devices, parallel execution, and detailed logs and screenshots. This cloud-based approach removes the need for physical devices, accelerates testing cycles, and helps teams deliver high-quality apps faster.



