Skip to content

Airtest Project

2.4 IOS Device Connection

ios-airtestIDE iOS-Tagent is a customized and optimized version based on Facebook's WebDriverAgent. It is developed to provide testing support for AirtestProject on the iOS platform. To use the Airtest project for testing on the iOS platform, you need to have a macOS and deploy the iOS-Tagent using Xcode. After that, you can connect to the iOS phone on either a Mac or Windows machine. Please click on this link to download the project code for local deployment. This project has been developed and tested on the following versions:

IOS Xcode
≥14 12.x
≥ 13 11.x
10.x-12.x 10.x
≥ 9.3 ≥ 9.3

In addition, starting from Airtest 1.1.8, we have added support for Appium's WebDriverAgent tool. Therefore, you can deploy iOS real devices using either Appium's WebDriverAgent tool or our Airtest iOS-Tagent tool, which provides great flexibility.

For lower versions of iOS (below iOS11), we recommend using our iOS-Tagent tool, while for higher versions of iOS, you are recommended to use Appium's WebDriverAgent tool for better compatibility.

We recommend the following tutorials for how to install Appium's WebDriverAgent:

  • Appium's WebDriverAgent tool - Installation guide: https://testerhome.com/topics/7220
  • Facebook's WebDriverAgent tool - Installation information: https://testerhome.com/topics/10463
  • Appium's WebDriverAgent tool - Troubleshooting: https://github.com/appium/WebDriverAgent/issues
  • Facebook's WebDriverAgent tool - Troubleshooting: https://github.com/facebookarchive/WebDriverAgent/issues

If you choose to install Appium's WebDriverAgent tool on a real iOS device following the above tutorial, you can now also use the AirtestIDE to connect to this iOS device: image The project is currently in the public testing phase and may have some issues. If there are any problems or suggestions for this project, you are welcome to submit them in the Issues section.

2.4.1 Supported Airtest APIs

With improvements, iOS-Tagent can now work with AirtestIDE and Airtest projects. It supports universal iOS APIs of Airtest.

- 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

Here are a few exceptions:

- wake: Not yet supported (the 'home' method can be used as a substitute)
- keyevent: Only supports 'home' event
- clear_app: Not yet supported
- install: Not yet supported
- uninstall: Not yet supported

2.4.2 Quickly Viewing the Screen Using Poco

Poco screen viewing function is now supported, and you can see the effect in the figure below.

ios-inspector

This function can achieve the best effect when used together with Poco and AirtestIDE. Please note that this function cannot be used if only the WDA project is deployed. Please make sure that the deployed project is our iOS-Tagent project.

2.4.3 Simple Deployment Process

Step 1: iOS-Tagent

Create a WebDriver server on the mobile phone to remotely control iOS devices and locate UI elements.

  • a. Download iOS-Tagent to the local computer.

git clone git@github.com:AirtestProject/iOS-Tagent.git

  • b. Open iOS-Tagent with Xcode and connect your iPhone to your Mac using a USB cable.

Select the project by going to the menu bar: Product -> Scheme -> WebDriverAgentRunner.

Select the real device by going to the menu bar: product -> Destination -> Choose your real device. chooseScheme - c. Launch Test by going to the menu bar: product -> Test. When you see the following log, it means that the iOS-Tagent has been launched successfully.

  Test Suite 'All tests' started at 2017-01-23 15:49:12.585
  Test Suite 'WebDriverAgentRunner.xctest' started at 2017-01-23 15:49:12.586
  Test Suite 'UITestingUITests' started at 2017-01-23 15:49:12.587
  Test Case '-[UITestingUITests testRunner]' started.
  t =     0.00s     Start Test at 2017-01-23 15:49:12.588
  t =     0.00s     Set Up

Learn more about how to successfully launch this project from here and here.

Step 2: Set up a proxy

With iproxy, the iPhone port can be mapped to the computer port, allowing access to the phone port through the computer port.

In general, accessing the Agent on a phone requires setting up a USB proxy, as accessing it directly through WiFi may cause issues. For more details and reasons, please refer to the Issues and detail section.

  • a. Install iproxy via Homebrew $ brew install libimobiledevice
  • b. Run iproxy $ iproxy 8100 8100

After the launch, try accessing http://127.0.0.1:8100/status in a browser. If you can access it and see some JSON-formatted phone information, it means the launch has been successful. Then, access http://127.0.0.1:8100/inspector and you will see the iPhone device screen on the browser.

One thing to note is that iproxy can only listen to localhost. If you want to connect your iPhone to Windows, you can use wdaproxy instead. Here are the steps:

  • Connect iPhone to Mac using a USB data cable.
  • Run wdaproxy on Mac to map the iPhone port to Mac port. For installation and running steps, refer to https://github.com/openatx/wdaproxy.
  • In the AirtestIDE on Windows, input the IP address and port of the Mac into the iOS address box, and click on the "connect" button.

Step 3: AirtestIDE

Connect to iPhone via IP and refresh the interface in real time for UI testing. After completing the above two steps, you can fill in the iOS address bar of AirtestIDE with the address http://127.0.0.1:8100, click on the "connect" button to connect the device, and start writing your Airtest test script.

connectDevice

ios-airtestIDE

2.4.4 Q&A

We anticipate that you may encounter many issues during the deployment process, so we have prepared a Q&A for you. If you have any questions or feedback for this project, please feel free to submit them in the Issues section.

1.Xcode version issues

2.Apply for a developer certificate

3.Log in to the developer account

4.Set up a developer certificate

5.Xcode failed to create provisioning profile

6.First-time installation, trust the device

2.4.5 License

iOS-Tagent has been customized and optimized based on WebDriverAgent.

WebDriverAgent is BSD-licensed. We also provide an additional patent grant.

Have fun with Airtest!