Skip to main content

Prerequisites

Before you can run tests on iOS devices, you’ll need to set up Appium and the iOS-specific dependencies:
  1. Install Appium Server and dependencies:
    # Install Appium globally
    npm install -g appium
    
    # Install Appium Doctor for diagnostics
    npm install -g appium-doctor
    
    # Install the XCUITest driver for iOS testing
    appium driver install xcuitest
    
  2. Verify your Appium installation:
    appium-doctor --ios
    
    This command will check your system specifically for iOS testing requirements and highlight any issues that need to be fixed.
  3. Start the Appium server:
    appium --allow-cors
    
    You’ll need to keep this server running in a separate terminal window while executing your tests.

Setting Up an iOS Simulator

Testpilot works with iOS simulators managed through Xcode. Here’s how to set one up:
  1. Install Xcode from the Mac App Store (requires macOS)
  2. Open Xcode and accept any license agreements
  3. Open the simulator by going to Xcode → Open Developer Tool → Simulator
  4. Create a new simulator device:
    • In Xcode, go to Window → Devices and Simulators
    • Click the ”+” button to add a new simulator
    • Choose a device type (iPhone 13 or newer recommended)
    • Select the latest iOS version
    • Give your simulator a descriptive name and click “Create”

Creating an iOS Test

Create a test file (e.g., ios-test.pilot.yaml) with the platform_config specifying your iOS app bundle identifier:
name: "iOS App Test"
context:
  - text: "Testing a native iOS application"
cases:
  - id: "ios-basic-001"
    name: "Basic iOS Navigation"
    description: "Test basic navigation in the iOS app"
    platform_config:
      ios_bundle: "com.example.MyApp"  # Replace with your app's bundle identifier
    steps:
      - "Verify the app launches successfully"
      - "Tap on the 'Login' button"
      - "Enter username and password"
      - "Tap the Submit button"
      - "Verify successful login"

Running iOS Tests

To run a test on an iOS simulator or device, use the following command. You must specify the --driver, --os, --runtime, --os-version, and --udid flags to ensure the test runs correctly on your iOS simulator:
testpilot test ios-test.pilot.yaml --driver appium --os ios --runtime native --udid <device-udid>
You can find your device’s UDID using
xcrun simctl list
To get a list of running sims, use:
xcrun simctl list booted
For testing web content in Safari on an iOS device:
testpilot test web-test.pilot.yaml --driver appium --os ios --runtime safari --os-version 18.5

Test Platform Configuration

The platform_config section of your test file is crucial for iOS testing:
platform_config:
  url: "https://example.com"      # For browser-based tests
  ios_bundle: "com.example.MyApp" # For native app tests
  • Use url for browser-based tests on iOS Safari
  • Use ios_bundle for native iOS app tests

iOS-Specific Considerations

When testing iOS applications, keep in mind:
  1. Permissions: iOS will prompt for permissions (camera, microphone, etc.). Your test steps should account for these permission dialogs.
  2. Security Features: iOS has stricter security than Android. Your app must be properly signed and provisioned for testing.
  3. App Installation: For simulators, you’ll need an .app file; for physical devices, you’ll need a signed .ipa file.
I