关于airtest群控制ios
1.安装carthage
brew install carthage
2.下载项目
git clone https://github.com/facebookarchive/WebDriverAgent
./Scripts/bootstrap.sh
#如果报错多半是node 版本的问题降版本https://registry.npmmirror.com/binary.html?path=node/v12.22.1/
2.构建时候报错统计
1.错误1
报错信息:Building for iOS, but the linked and embedded framework 'RoutingHTTPServer.framework' was built for iOS + iOS Simulator
解决办法:
在 targets 下的类别中,依次将 Build Settings 里的 Validate Workspace 修改为 Yes
2.报错2
报错信息:/WebDriverAgent/Carthage/Build/iOS/RoutingHTTPServer.framework/Headers/RouteResponse.h:2:9: Double-quoted include "HTTPResponse.h" in framework header, expected angle-bracketed instead
解决办法:
在 project 的 Build Settings 信息中,将 Quoted Include In Framework Header 修改为 false
3.报错3
WebDriverAgent-master/Carthage/Build/iOS/RoutingHTTPServer.framework/Headers/RouteResponse.h:8:1: 'assign' property of object type may become a dangling reference; consider using 'unsafe_unretained'
解决方式:将 assign 改为 strong ,并重新build,如下的两个错误同步解决掉(或:修改assign为unsafe_unretained)
4.报错4
sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
解决办法:在 project 的 Build Settings 信息中,将require only app-extension-safe api 修改为 false
5.报错5
WebDriverAgent-master/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m:29:1: Implementing deprecated method
解决方法:将recordFailureWithDescription
修改为recordIssue
3.用xcode将/WebDriverAgent在手机中成功运行一次
4.使用tidevice离线启动WebDriverAgent
1.安装
pip3 install tidevice
2.相关指令
tidevice list #查看已连接设备
tidevice applist #查看设备上的第三方应用包名
tidevice -u $UDID #指定设备
tidevice xctest -B app报名 #运行app
3.注意事项
多台设备时间
tidevice -u 13bddfbf8c68b7018c2424fb6653e88cb0c32412 xctest -Bcom.facebook.WebDriverAgentRunnerwwww.xctrunner
#这台通过WebDriverAgent项目中全局8100改成8101
iproxy 8101 8101 -u 13bddfbf8c68b7018c2424fb6653e88cb0c32412 #必须加u
tidevice -u a5cf1c66d6f78f3fb711b9604a7187bc6c391210 xctest -B com.y.w.y.xctrunner
iproxy 8100 8100 -u a5cf1c66d6f78f3fb711b9604a7187bc6c391210
4.airtest群控代码
1.安装
pip3 install airtest
pip3 install poco
pip3 install poco-ui
2.群控代码
import random
import time
from airtest.core.api import *
from airtest.cli.parser import cli_setup
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
from poco.drivers.ios import iosPoco
from multiprocessing import Process
kuaituantuan_code_table = yunji_db['kuaituantuan_code']
def get_ios_poco(index):
print(index)
for index_int in range(index+1):
print(index_int)
connect_device(f"iOS:///http://127.0.0.1:810{index_int}")
set_current(index) #本质G.DEVICE_LIST 群控核心用好G这个对象
dev = device()
poco = iosPoco(device= dev)
return poco,dev
def Initialization(index):
poco,dev =get_ios_poco(index)
keyevent("Home")
if __name__ == '__main__':
process_1 = Process(target=Initialization, args=(0,))
process_2 = Process(target=Initialization, args=(1,))
process_1.start()
process_2.start()
process_1.join()
process_2.join()