Skip to main content

IOSDriver API Reference

IOSDriver

iOS device driver communicating via HTTP REST to the iOS Portal app. Unsupported methods:
  • drag() — not in supported set
  • install_app() — not in supported set
  • press_button()home only

IOSDriver.__init__

Initialize the IOSDriver instance. Arguments:
  • url str - iOS Portal URL (e.g., “http://127.0.0.1:6643”)
  • bundle_identifiers List[str] | None - Optional list of custom app bundle identifiers
Usage:
Supported methods:
Setup Requirements:
  1. Build and run the iOS Portal via Xcode (runs as a UI test)
  2. Forward port with iproxy 6643 6643
  3. Use http://127.0.0.1:6643 as the URL
See Device Setup — iOS for full instructions.

Lifecycle Methods

IOSDriver.connect

Create an HTTP client and verify connectivity by calling /device/date.

IOSDriver.ensure_connected

Connect if not already connected. Safe to call multiple times.

Input Action Methods

IOSDriver.tap

Tap at coordinates. Arguments:
  • x int - X coordinate
  • y int - Y coordinate
Usage:

IOSDriver.swipe

Swipe from one point to another. Arguments:
  • x1 int - Starting X coordinate
  • y1 int - Starting Y coordinate
  • x2 int - Ending X coordinate
  • y2 int - Ending Y coordinate
  • duration_ms float - Duration in milliseconds
Usage:

IOSDriver.input_text

Input text into the currently focused element. Arguments:
  • text str - Text to input (supports Unicode)
  • clear bool - Clear existing text before input
Returns:
  • bool - True if input succeeded, False otherwise
Usage:

IOSDriver.press_button

Press a named system button. Supported buttons: home Raises ValueError for unsupported button names. Arguments:
  • button str - Button name (case-insensitive)
Usage:

App Management Methods

IOSDriver.start_app

Launch an app by bundle identifier. Arguments:
  • package str - Bundle identifier (e.g., “com.apple.MobileSMS”)
  • activity str | None - Ignored on iOS (for API compatibility)
Returns:
  • str - Result message
Common bundle identifiers:
  • Messages: com.apple.MobileSMS
  • Safari: com.apple.mobilesafari
  • Settings: com.apple.Preferences
  • Calendar: com.apple.mobilecal
  • Photos: com.apple.mobileslideshow
  • Maps: com.apple.Maps
  • Contacts: com.apple.MobileAddressBook
Usage:

IOSDriver.list_packages

List known bundle identifiers. Arguments:
  • include_system bool - Include system apps (default: False)
Returns:
  • List[str] - List of bundle identifiers
Notes:
  • Returns union of bundle_identifiers + system apps (if included)
  • Does not query device for installed apps

IOSDriver.get_apps

Return known apps as list of dicts with package (bundle identifier) and label (human-readable name). System apps are mapped to friendly names (e.g., com.apple.mobilesafariSafari). Third-party bundle identifiers are humanized from the last segment. Arguments:
  • include_system bool - Include system apps (default: True)
Returns:
  • List[Dict[str, str]] - List of dicts with ‘package’ and ‘label’ keys

State and Observation Methods

IOSDriver.screenshot

Capture device screen as raw PNG bytes. Arguments:
  • hide_overlay bool - Unused on iOS (for API compatibility)
Returns:
  • bytes - Raw PNG image data
Usage:

IOSDriver.get_ui_tree

Return unified state from the iOS portal. Mobilerun requests GET /state?timeout=4, giving the portal a single 4-second state collection budget. There is no Mobilerun-side retry on iOS state fetches. Returns: Dictionary with:
  • a11y_tree - The accessibility tree elements
  • phone_state - Dict with currentApp and keyboardVisible
  • device_context - Additional device context
Usage:

IOSDriver.get_date

Get the current date and time from the device. Returns:
  • str - Date string, or empty string on failure

Unsupported Methods

The following DeviceDriver methods are not in supported and will raise NotImplementedError:

drag()

Not supported on iOS.

install_app()

Not supported on iOS.

Instance Properties


Example Usage

Note: For higher-level interactions with element indexing and structured results, use action functions with ActionContext (see MobileAgent) rather than calling the driver directly.

See Also