Step-by-Step Guide to Set Up iOS Test Automation with Appium and Java

Step-by-Step Guide to Set Up iOS Test Automation with Appium and Java

5 April 2024 Stephan Petzl Leave a comment Tech-Help

Automated testing is a critical component of the continuous integration and deployment pipeline. Appium is a popular open-source tool for automating native, mobile web, and hybrid applications on iOS mobile, Android mobile, and Windows desktop platforms. In this guide, we will focus on setting up Appium for iOS app testing using Java.


  • Java Development Kit (JDK)
  • Eclipse IDE or any Java IDE of your choice
  • Appium Desktop Client or Appium Server Node Module
  • Xcode (for iOS)
  • An iOS Simulator or Real Device

Setting up the Environment

  1. Create a new Java project in Eclipse: Start by creating a new Java project in your Eclipse IDE.
  2. Import Selenium and Appium Client Libraries: You will need to download and import the Selenium Server jar files and the Appium Client libraries.
    • Right-click on your project in Eclipse.
    • Navigate to Properties → Java Build Path → Libraries.
    • Click ‘Add External JARs’ and select the downloaded Selenium and Appium client jars.
  3. Download and Launch Appium: If you prefer a GUI, download the Appium desktop client. Alternatively, install the Appium server using npm (Node.js package manager) and start it via the command line.
  4. Configure Your Device/Simulator: To run tests on a real iOS device, you will need to gather details such as ‘deviceName’, ‘platformVersion’, ‘UDID’, and ‘Bundle ID’. For an iOS simulator, you will need ‘deviceName’, ‘platformVersion’, and the path to your .app file.
  5. Set Desired Capabilities: In Appium, select the desired capabilities that match your testing device or simulator. These capabilities should also be reflected in your test script.

Running Your Test Script

  1. Launch the Appium server. Ensure it is running before executing your test script.
  2. Run your test script from the Eclipse IDE. Ensure that your script includes the correct desired capabilities and points to the Appium server’s URL.

Sample Test Script

Here is a simplified example of a test script that you can use as a starting point:

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class IOSAppTest {
    public static void main(String[] args) throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "iPhone Simulator");
        capabilities.setCapability("platformVersion", "14.4");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("app", "/path/to/");
        capabilities.setCapability("automationName", "XCUITest");
        RemoteWebDriver driver = new RemoteWebDriver(new URL(""), capabilities);
        // Your test code goes here

Next Steps

Once you have successfully run your first test script, you can expand your test suite by adding more test cases and utilizing advanced Appium features. Remember, continuous learning and practice are key to mastering iOS test automation with Appium and Java.

Happy testing!

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