Skip to content

iOS automated testing

Airtest supports iOS automated testing. After deploying iOS-Tagent for iOS phones on Mac, you can use AirtestIDE to connect devices. Just like the IDE connects to an Android device, you can see the real-time projection of the phone and control the phone.iOS testing is not limited to real machine testing. iOS simulators can also be used. After deployment on the Mac side, it can also be used for remote connection on windows in the same local area network. It supports both airtest image recognition and poco UI retrieval.

This article describes the deployment process of iOS automated testing, provides a simple test script, and lists common problems during iOS testing.

Functional support

  • Support AirtestIDE connection, and iPhone can be controlled in real time
  • Support basic operations such as launching the app, clicking, swiping, typing, taking screenshots, etc.
  • Supports control retrieval technology and image recognition
  • Automated script recording, one-click playback, report viewing and other basic functions
  • Support real machine or simulator

Installation and deployment

Version requirements:
- Mac Xcode ≥ 9.3
- iPhone iOS ≥ 9.3
- When iOS version ≥9.3 and ≤10, it is based on the old version of the xcode SDK. Therefore, it is recommended to use Xcode version ≤ 10.1 to start iOS-Tagent, otherwise the problem of incomplete screen capture will occur.

Deployment process

  1. Download iOS-Tagent on your Mac and use Xcode to start Test. For the specific startup process, please refer to When Xcode's log window outputs the following information, it means that the deployment was successful.

  2. Start the agent and run iproxy 8100 8100 on the command line. After running the agent, you can open in your browser to see if the iOS device can connect successfully.

iproxy is a small tool that comes with usbmuxd, and its role is to map a certain port of the device to a certain port of the computer. Mac can be installed via brew install usbmuxd.

iproxy 8100 8100 means to map the 8100 port of the mobile phone to the 8100 port of the computer. This way we can access the mobile phone by accessing the computer's 8100 port.

  1. In the device window of AirtestIDE, enter the address: http: // 8100 orhttp: //x.x.x.x (MAC IP): 8100:


Click the Connect button to connect the iOS device, as shown in the figure:


Support for iOS simulator in Xcode

The deployment process of iOS Simulator in Xcode is the same as the real machine, but you can omit step 2 and do not need to run another proxy.

When Xcode's log window sees the following content, it can directly connect with the address http: //x.x.x.x: 8100, which is the address inServerURLHere displayed in the log:

    WebDriverAgentRunner-Runner[xxx:xxx] ServerURLHere->http://x.x.x.x:8100<-ServerURLHere

Support Windows connection

We can also connect a remote iOS device on Windows, but we still need a Mac computer and Xcode environment.First start iOS-Tagent on the Mac according to the deployment tutorial above, and then no longer use iproxy to start the agent, but use wdaproxy instead.Because iproxy only supports local port mapping, andwdaproxy can support remote IP mapping. This means that we can access the iOS device connected to the Mac computer by accessing the IP on the second PC.

Install wdaproxy through brew install openatx/tap/wdaproxy

The usage method is the same as iproxy,wdaproxy 8100 8100. If you do not fill in the port, 8100 will be used by default:


start testing

The iOS test is similar to other devices and supports image recognition and UI retrieval. Here is a brief example of an iOS test:
1. Connect the device 2. Click on the home button 3. Screenshot 4. Perform a swipe operation 5. Use poco to click app Safari 6. Use poco to click the browser's search box to get focus 7. Type "airtest" in the search box 8. Swipe down on the search page 9. Determine if the airtest official website address exists

from airtest.core.api import *
from poco.drivers.ios import iosPoco
poco = iosPoco()

swipe(Template(r"tpl1561985939879.png", record_pos=(0.356, -0.174), resolution=(750.0, 1334.0)), vector=[-0.685, 0.0481])


poco("People also search for").swipe([-0.0541, -0.4206])
exists(Template(r"tpl1560844284543.png", record_pos=(-0.292, 0.688), resolution=(750, 1334)))


common problem

  1. How to install apps in the simulator

    • Change xx.ipa to and extract it to
    • Open the simulator and run xcrun simctl install booted in the terminal

    tips: You cannot install the real app package on the iOS simulator. The real machine app is based on the arm, and the simulator runs on the X86 instruction set. Forcibly installing it will cause a flashback problem.

  2. How to conduct iOS multi-machine test \ The multi-machine testing function of iOS is not currently open, so stay tuned.

  3. Api support status \ Please note that iOS devices are very different from Android devices. The following common Airtest API are supported on iOS:

    • start_app: OK
    • stop_app: OK
    • snapshot: OK
    • home: OK
    • touch: OK
    • swipe: OK
    • text: OK
    • wait: OK
    • exists: OK
    • find_all: OK
    • assert_exists: OK
    • assert_not_exists: OK

    But the following API are not supported: - wake: Not supported yet (considering using the home method)
    - keyevent: Only supports home event - clear_app: Not supported yet - install: Not supported yet - uninstall: Not supported yet