Setting Up Appium on macOS for Java-Based Automation Testing

Setting Up Appium on macOS for Java-Based Automation Testing

10 November 2024 Stephan Petzl Leave a comment Tech-Help

Automating mobile tests on macOS using Appium can be a complex process, especially when integrating with Java. This guide provides a detailed step-by-step approach to setting up Appium on your Mac, enabling seamless testing on both Android and iOS devices.

Pre-requisites

  • Java Development Kit (JDK) version 6 or above
  • Android SDK
  • Xcode for iOS testing (no need to modify Bash profile)

Step-by-Step Installation Guide

Step 1: Install Java

Download Java JDK from the official Oracle website and install it on your Mac.

Step 2: Set Up Environment Variables

Configure your Bash profile to include paths for Java, Android SDK, and Maven:

export PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/platform-tools":$PATH
export PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/tools":$PATH
export PATH=$HOME/local/bin:$PATH
export ANDROID_HOME=/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140321/sdk
export PATH="/Users/your_username/Desktop/apache-maven-3.2.2/bin":$PATH
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

Step 3: Install Node.js

Open Terminal and execute the following commands to install Node.js without using SUDO:

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install

Step 4: Install Appium

Once Node.js is installed, run the following command to install Appium:

npm install -g appium

Step 5: Start Appium Server

To start the Appium server, execute the following command:

appium &

Step 6: Run Your First Test

Attach your Android device via USB, navigate to your Java project’s root directory in Terminal, and execute your test:

cd /Users/your_username/Documents/workspace/ApiumJUnit
mvn -Dtest=test.java.com.saucelabs.appium.AndroidContactsTest test

Enhancing Your Automation Testing with Repeato

While Appium is a powerful tool for mobile automation, it can sometimes be slow and tests may become unstable. This is where Repeato can make a significant difference. As a no-code test automation tool, Repeato offers faster test creation and execution using advanced computer vision and AI technologies. It simplifies the process of automated testing for iOS and Android apps, making it an ideal choice for developers and testers looking for efficiency and reliability.

For further reading on setting up Appium or exploring advanced testing techniques, check out our documentation or visit our blog.

Like this article? there’s more where that came from!