iOS
Midscene connects to iOS devices through WebDriverAgent to automate apps and system interfaces.
This guide covers WebDriverAgent setup, model configuration, Playground, and JavaScript SDK integration with @midscene/ios.
See it in action
Prompt: Open Twitter and like the first post from @midscene_ai.
View the full report, or explore more Midscene showcases.
Get started
Prepare the iOS environment
WebDriver is a W3C standard protocol for browser automation. It provides a common API for controlling browsers and applications. The protocol defines how clients and servers communicate, which allows automation tools to control interfaces across platforms.
The Appium team and other open source communities maintain tools that expose desktop and mobile automation through WebDriver. These tools include:
- Appium: a cross-platform mobile automation framework.
- WebDriverAgent: a service for iOS device automation.
- Selenium: a Web browser automation tool.
- WinAppDriver: a Windows application automation tool.
Midscene supports the WebDriver protocol. You can use AI models to automate any compatible device. Midscene can understand interface context, perform multistep operations, validate results, and extract data in addition to clicking and typing.
On iOS, Midscene connects through WebDriverAgent. You can then use natural-language instructions to control iOS apps and system interfaces.
Before continuing, make sure WebDriverAgent can communicate with the device.
Install Node.js
Install Node.js 18 or higher.
Set up WebDriverAgent
Before getting started, you need to set up the iOS development environment:
- macOS (required for iOS development)
- Xcode and Xcode command line tools
- iOS Simulator or real device
Configure WebDriverAgent
Before using Midscene iOS, you need to prepare the WebDriverAgent service.
WebDriverAgent version must be >= 7.0.0
Please refer to the official documentation for setup:
- Simulator Configuration: Run Prebuilt WDA
- Real Device Configuration: Real Device Configuration
Verify WebDriverAgent
After completing the configuration, you can verify whether the service is working properly by accessing WebDriverAgent's status endpoint:
Access URL: http://localhost:8100/status
Correct Response Example:
If you can successfully access this endpoint and receive a similar JSON response as shown above, it indicates that WebDriverAgent is properly configured and running.
Launch Playground
Playground is the fastest way to validate the connection and try core capabilities such as aiAct, aiQuery, and aiAssert without writing code. It shares the same core as @midscene/ios, so anything that works here will behave the same once scripted.
- Launch the Playground CLI:
- Click the gear button to enter the configuration page and paste your API key config. Refer back to Model configuration if you still need credentials.

Use the JavaScript SDK
Once Playground works, move to a repeatable script with the JavaScript SDK.
Configure the model
Set the model configuration through environment variables. See Model strategy for guidance on choosing a model.
For all configuration options, see Model configuration.
Install dependencies
Write a script
Save the following code as ./demo.ts. It opens Safari on the device, searches eBay, and asserts the result list.
Run the script
View the report
Successful runs print Midscene - report file updated: /path/to/report/some_id.html. Open the generated HTML file in a browser to replay every interaction, query, and assertion.
API reference and more resources
For constructors, helper methods, and platform-specific device APIs, see the iOS section of the API reference. It includes detailed parameter lists and advanced topics such as custom actions. For APIs shared across platforms, see the Common section.
FAQ
Why can't I control my device through WebDriverAgent even though it's connected?
Please check the following:
- Developer Mode: Ensure it's enabled in Settings > Privacy & Security > Developer Mode
- UI Automation: Ensure it's enabled in Settings > Developer > UI Automation
- Device Trust: Ensure the device trusts the current Mac
What are the differences between simulators and real devices?
How to use custom WebDriverAgent port and host?
You can specify WebDriverAgent port and host through the IOSDevice constructor or agentFromWebDriverAgent:
For remote devices, you also need to set up port forwarding accordingly:
How to get smoother live screen preview in Playground?
Playground's screen preview supports two modes:
- Polling mode (default): Captures screenshots one by one via the WDA screenshot API, achieving ~5-10fps.
- Native MJPEG stream (recommended): Proxies WDA's built-in MJPEG Server directly for higher frame rate and lower latency.
To enable the native MJPEG stream, forward the WDA MJPEG Server port (default 9100) to localhost:
Playground automatically probes port 9100 on startup. If available, the log will show MJPEG: streaming via native WDA MJPEG server; otherwise it falls back to polling mode automatically.
More
- For every Agent method, check the API reference (Common).
- For iOS-specific APIs, see API reference (iOS).
- Use YAML automation scripts and command-line tools.
- Demo projects
- iOS JavaScript SDK demo: https://github.com/web-infra-dev/midscene-example/blob/main/ios/javascript-sdk-demo
- iOS + Vitest demo: https://github.com/web-infra-dev/midscene-example/tree/main/ios/vitest-demo

