# 1.3 IOS test **This article is over 600 words long, it may take about 2 minutes to read the full text** ## Overview This article introduces how to get started with AirtestIDE for IOS testing. It is divided into the following sections: * About iOS automated testing * Deploy iOS-Tagent * Connect to iOS devices * Record and run scripts using Airtest image recognition * Record and run scripts using Poco mode * FAQ ## About iOS automated testing There are several common scenarios for automating test solutions for iOS. Apple's recommendation is to write test code directly in the xcode project, then test it with xcode. The problem with this approach is that the coupling degree between test's code and project's code is relatively high and complex. Airtest Project provides a new way of thinking: using Python as scripting language and image recognition to automate testing. It also uses the optimized WebdriverAgent ([iOS-Tagent](https://github.com/AirtestProject/IOS-Tagent)) as the underlying framework of runtime device control. This greatly optimizes the execution efficiency. IOS automation has never been easier and more convenient. ## Deploy iOS-Tagent The first step in performing an iOS test is to deploy iOS-Tagent. For a more specific deployment tutorial, see [github link](https://github.com/AirtestProject/IOS-Tagent) or [AirtestIDE official documentation](http:/ /airtest.netease.com/docs/docs_AirtestIDE-en_US/1_quick_start/5_ios_connection.html) After following the steps in the deployment tutorial, a log like the one below will indicate that the project has started 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 ``` In general, the Agent on the phone should be accessed by setting up the usb proxy, as there may be problems accessing directly through wifi. For further explanation on this, please refer to [Issues](https://github.com/facebook/WebDriverAgent/ Wiki/Common-Issues) and [detail](https://github.com/facebook/WebDriverAgent/issues/288) ``` Iproxy can be used $ brew install libimobiledevice $ iproxy 8100 8100 | After the startup has finished, try to visit http://127.0.0.1:8100/status | If some json-formatted information is displayed, the startup was successful. ``` ## Connect to iOS devices After completing the above steps, you can start using AirtestIDE to connect to the device. In simple terms, connecting to an iOS device requires only to: * Open AirtestIDE * Enter url and click connect After deploying iOS-Tagent, open AirtestIDE and find the iOS connection window. ![](3_get_started_with_iOS_test/1_iOS_connection_panel.png) Click "connect" to connect to the device ![](3_get_started_with_iOS_test/2_iOS_connected.png) ## Record and run scripts using Airtest image recognition Airtest image recognition system is our solution to record and play back operations such as clicking and sliding. The following describes the use of Airtest recognition system: * Select the calculator icon to be clicked * Playback script Select the touch button to record a click operation. ![](3_get_started_with_iOS_test/3_touch_image.png) Select the button in the screen that needs to be clicked ![](3_get_started_with_iOS_test/4_select_target_image.png) Play back the operation ![](3_get_started_with_iOS_test/5_record_airtest_script.gif) For more on automatic recording, [see](http://airtest.netease.com/docs/docs_AirtestIDE-zh_CN/2_airtest_script/1_airtest_record.html#id4) ## Record and run scripts using Poco mode When using Poco for recording and running scripts, the elements on the current screen can be accurately located in the actual UI structure tree, so we can retrieve information such as the position. Here's how iOS uses Poco to record and run: * Opens poco selection component * Shows a script playback process, i.e. opens the calculator and performs simple calculations In the poco window, select iOS to open Poco. ![](3_get_started_with_iOS_test/6_poco_mode.png) For specifics on how to use poco [see](../1_online_help/poco_intro.html) The following describes the use of Poco for recording and playback. ![](3_get_started_with_iOS_test/7_run_poco_script.gif) ## FAQ **Q1. iOS Are connections to multiple devices supported?** * There are, use the [set_current method](https://airtest.readthedocs.io/en/latest/all_module/airtest.core.api.html#airtest.core.api.set_current) to switch the current operating device. **Q2. What to do if the connection fails?** * Check [iOS-Tagent's github warehouse](https://github.com/AirtestProject/iOS-Tagent) for more information **Q3. Does it support test games?** * It does, for more information, check [poco page](../1_online_help/poco_intro.html)