How to Seamlessly Integrate Appium with Xcode Simulator for iOS Testing

Wavda Aniva
3 min readJul 20, 2023

Are you looking for a way to streamline your iOS testing process? If so, integrating Appium with the Xcode emulator is a great way to automate your testing and ensure your app runs smoothly on different iOS devices. By combining the power of Appium and the Xcode emulator, you can quickly and easily set up your test environment and run tests on a wide range of iOS devices. In this article, we’ll show you how to seamlessly integrate Appium with the Xcode emulator for iOS testing, so you can improve your app’s quality and ensure a great user experience.

Part 1: Installations

  1. Install Xcode on your Mac through the App Store.
  2. Install Homebrew if you don’t have it already. You can install it by running the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. Install Node.js using the following commands in your terminal:

brew install node

4. Install Appium using the following commands in your terminal:

npm install -g appium

5. Install Appium Doctor. It checks your system and tells you how to set up Appium. You can install it by running the following command in your terminal:

npm install -g appium-doctor

6. Run Appium Doctor to check if everything is set up correctly. You can run it by running the following command in your terminal:

appium-doctor

If you see any issues, follow the instructions given by the Appium Doctor to fix them.

Part 2: Emulator Setup

1. Launch the Xcode emulator by running the following command in your terminal, and then install your application:

open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

2. Install your application on the device emulator. In this example, we’ll use the following Sauce Labs Demo application for testing: https://github.com/saucelabs/sample-app-mobile/releases

3. Get the list of available devices information, such as their deviceName, platformVersion, and udid using the following command:

xcrun xctrace list devices

4. Get the application’s bundleId based on the list of installed applications for a specific device udid using the following command:

xcrun simctl listapps device-udid-goes-here

Part 3: Getting Element Locator using Appium Inspector

1. Install and run Appium Inspector: https://github.com/appium/appium-inspector/releases.

2. Set the remote path to “/wd/hub”

3. Set the desired capabilities, e.g.

{
"platformName": "iOS",
"appium:platformVersion": "16.4",
"appium:deviceName": "iPhone 14 Pro",
"appium:automationName": "XCUITest",
"appium:udid": "auto",
"appium:bundleId": "com.saucelabs.SwagLabsMobileApp",
"appium:noReset": "true"
}

4. Start Appium by running the following command in your terminal:

appium --base-path /wd/hub --allow-cors

5. Click on “Start Session” in the Appium Inspector. You should be able to start inspecting the element locators as follows once Appium Inspector has successfully connected to the simulator:

Part 4: Running Automated Tests

Create a new Appium project in your preferred programming language and specify the desired capabilities to launch the Xcode emulator. For example, in JavaScript using WebdriverIO, you can find the step-by-step instructions in this article, Streamlining Mobile App Testing with WebdriverIO and Appium.

Add the following settings to your test project configuration file:

// ...

runner: 'local',
path: '/wd/hub',
port: 4723,
allowCors: true,

services: [
['appium', {
command: 'appium',
logPath: './logs/'
}]
],

capabilities: [{
'appium:platformName': 'iOS',
'appium:automationName': 'XCUITest',
'appium:platformVersion': '16.4',
'appium:deviceName': 'iPhone 14 Pro',
'appium:udid':'auto',
'appium:bundleId': 'com.saucelabs.SwagLabsMobileApp',
'appium:noReset': true
}],

// ...

Note that you’ll need to replace the desired capabilities with your own values.

That’s it! You should now be able to run your Appium tests on the Xcode emulator.

--

--

Wavda Aniva

A curious potato exploring new things on software quality