How to Set Up Appium for Testing Android Devices

Appium is an open-source mobile automation tool that enables testing of native, hybrid, and mobile web applications on Android and iOS devices. It allows testers to write automation scripts in different programming languages like Java, Python, JavaScript, and C#, making it a versatile choice for mobile testing. Below is a detailed guide on setting up Appium for testing Android devices.

Install Java and Configure Environment Variables

Since Appium is built on Java, installing the Java Development Kit (JDK) is the first step.

  • Download and Install JDK from the official Oracle site. After installation, verify it by running the command:
  • java -version
  • Set Java Environment Variables by adding JAVA_HOME to system variables. The path should point to your JDK installation folder.
  • Update the PATH variable by adding JAVA_HOME/bin to ensure Java is accessible from the command line.

Install Android Studio and Configure Android SDK

To test on Android devices, you need Android Studio and SDK tools.

  • Download and Install Android Studio from the official Android Developer website.
  • Open SDK Manager inside Android Studio and install:
  • Android SDK
  • Platform tools
  • Build tools
  • Set Environment Variables:
  • Add ANDROID_HOME as a system variable pointing to your SDK location.
  • Update the PATH variable with:
  • %ANDROID_HOME%platform-tools
  • %ANDROID_HOME%tools
  • %ANDROID_HOME%toolsbin
  • Verify ADB (Android Debug Bridge) by running:
  • adb devices
  • If your connected device appears in the list, ADB is working correctly.

Install Node.js and Appium

Appium requires Node.js to run.

  • Download and Install Node.js from https://nodejs.org/.
  • Verify Installation using:
  • node -v
  • npm -v
  • Install Appium Globally using NPM:
  • npm install -g appium
  • appium -v # To verify installation
  • Install Appium Doctor to check for missing dependencies:
  • npm install -g appium-doctor
  • appium-doctor
  • Fix any issues if reported.

Install Appium Desktop and Appium Inspector

Appium Desktop provides a graphical interface to start and manage the Appium server.

  • Download and Install Appium Desktop from GitHub Releases.
  • Open Appium Desktop and start the server.
  • Install Appium Inspector, a tool that helps locate UI elements for mobile automation.

Enable Developer Mode and USB Debugging on Android Device

To test on a real Android device, enable Developer Mode and USB Debugging.

  • Enable Developer Mode by navigating to Settings → About Phone and tapping Build Number 7 times.
  • Enable USB Debugging from Developer Options in settings.
  • Connect the Android device to your computer via USB and run:
  • adb devices
  • If your device appears, it is properly connected.

Start the Appium Server and Run Test Scripts

Once Appium is installed and configured, you can start writing test scripts using Selenium WebDriver with Appium.

  • Launch Appium Desktop and click the “Start Server” button.
  • Use Appium Inspector to find element locators in the mobile application.
  • Write and execute test scripts using a test automation framework like JUnit, TestNG, or Cucumber.

Conclusion

Setting up Appium for Android testing requires installing Java, Android SDK, Node.js, and Appium, followed by configuring the environment variables and connecting a real device or emulator. With Appium Inspector and a test automation framework, you can automate UI testing for Android applications efficiently.

Leave a comment

Your email address will not be published. Required fields are marked *