How to Automate iOS App Using Appium on Mac

The iOS market is rapidly expanding, making iOS testing crucial for delivering top-notch mobile applications that satisfy and retain users. With users’ expectations growing at a rapid pace, companies continuously release updated versions of apps to meet these demands. In this scenario, automation testing becomes indispensable for development and testing professionals who strive to deliver exceptional apps within tight deadlines. Appium, the most widely used framework for mobile app testing, allows for executing automated tests for both native and hybrid applications on Android and iOS devices, resulting in faster and more accurate results. This article will delve into iOS app testing automation using Appium.

What is Appium?

Appium is an open-source automation testing framework that supports apps on various platforms like iOS, Android, macOS, and Windows. Similar to Selenium, it enables testers to write test scripts in programming languages like JavaScript, Java, Ruby, Python, PHP, and C#, which can be used for testing Android and iOS platforms.

How Does Appium iOS Testing Work?

Appium uses RESTful services to send JSON files and automatically interact with iOS applications through UI elements such as text labels and buttons, using Apple’s UIAutomation API for automated app testing. The bootstrap.js file acts as a TCP server, sending test commands to perform actions on iOS devices by leveraging Apple’s UIAutomation API framework.

How Appium iOS Testing works

Image Source:

Why Use Appium for Testing iOS Devices?

Appium offers several features that make it an ideal choice for automated testing on iOS devices:

  • It is an open-source framework, eliminating the need to invest in expensive licensed tools and frameworks.
  • With its built-in XCUITest driver, Appium generates detailed information logs and improves debugging efforts through better analysis of test results.
  • It allows for code reusability written for iOS devices to be used for testing Android devices, saving time and effort when testing hybrid apps.
  • Appium enables testing applications on various versions of iOS devices, ensuring cross-platform compatibility.
  • It provides real-time monitoring of tests on real devices, guaranteeing excellent reliability.

Prerequisites for Appium iOS Testing

Before running Appium tests on iOS devices, certain prerequisites need to be fulfilled:

  • Install Homebrew (for managing missing packages)

     brew install carthage
  • Install Carthage (for managing dependencies)

     brew install carthage
  • Install Node & NPM

     brew install node
  • Install Java and set up the environment variables

  • Install Eclipse IDE for Java

  • Install Maven

     brew install maven
  • Install Appium

     npm install -g appium
  • A Mac computer with macOS 10.11 or 10.12, and a device with iOS 9.3 or higher

  • Install XCode 11 (XCode 7 or higher is required)

     npm install -g ios-deploy
  • Install XCUITest Driver

  • Install TestNG

Getting Started with Running Appium Tests on iOS Devices

  1. Starting the Appium Server: Launch the Appium server to start the testing process.
    Appium server running for iOS device
    Appium Server runs for iOS device.

  2. Getting the iOS Device’s Details: Retrieve the details of the iOS device used for testing, including the device name, iOS version, and bundle ID. These details are required to set the desired capabilities. Since this example uses the XCUITest driver for iOS testing, the automationName needs to be set to XCUITest.

  3. Writing the Appium Test Script for iOS Devices: Create a new project in Eclipse and begin writing the Appium test script. Set the desired capabilities and instantiate the Appium Driver. For instance, to open the Google Chrome app on the tested iPhone, set the bundle ID to

import io.appium.java_client.ios.IOSDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Edition041_iOS_Real_Device {
    private IOSDriver driver;

    public void setUp() throws MalformedURLException {
        // Setting Desired Capabilities
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "12.4.7");
        capabilities.setCapability("deviceName", "iPhone 7");
        capabilities.setCapability("udid", "<your iPhone’s udid>");
        capabilities.setCapability("bundleId", "");
        capabilities.setCapability("xcodeOrgId", "<your org id>");
        capabilities.setCapability("xcodeSigningId", "<your signing id>");
        capabilities.setCapability("updatedWDABundleId", "");

        driver = new IOSDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities);

    public void tearDown() {
        if (driver != null) {

    public void testFindingAnElement() {
        driver.findElementByAccessibilityId("Login Screen");

In the test script, utilize the UDID of the iPhone, the iOS version, and the bundle ID details (in this example, the Google Chrome app’s bundle ID is to set the desired capabilities and instantiate the Appium Driver. Running this script will open the Google Chrome app on the connected iOS device.

Inspecting UI Elements for iOS

Unlike Android, which provides the UIAutomatorViewer tool, iOS doesn’t have a dedicated tool for identifying iOS elements. However, testers can employ the Appium Desktop Inspector to inspect UI elements on iOS.

Best Practices for Running Appium iOS Tests

To ensure successful Appium iOS testing, follow these best practices:

  • Carefully perform the installation process and manage all dependencies properly.
  • Use real devices instead of simulators or emulators for accurate results. BrowserStack offers real iOS devices, allowing QAs to perform automated app testing on different versions of real iOS devices.
  • Record functions using Appium and inspect elements using Appium Desktop Inspector for easy and accurate debugging.
  • Double-check the bundle ID of the application under test to ensure desired results.
  • Make sure the app is already installed on the device before running tests.

On a Closing Note

Appium enables accurate and comprehensive automated testing of hybrid, native, and web applications, eliminating bugs, anomalies, and any issues that may disrupt the user experience. Running Appium tests on real mobile devices generates 100% accurate results, as it involves monitoring apps under real user conditions. BrowserStack App Automate offers cloud-based access to the latest and legacy Android, iOS, and Windows devices installed with real operating systems. App Automate requires no additional setup, helping testers save time and meet deadlines faster. Test your Appium iOS tests on thousands of real devices, ensuring cross-platform compatibility and excellent user-friendliness.

Try Appium iOS Testing on Real Device Cloud.