前提:已经安装了Appium1.6版本,我这里用的是GUI版本
环境要求:
真机iOS9.3及以上
macOS 10.11或10.12
Xcode7及以上
安装步骤如下
第一步:iOS真机启动需要安装libimobiledevice和ios-deploy工具
1.安装
libimobiledevice
【brew install libimobiledevice —HEAD】
2.安装ios-deploy
【npm install -g ios-deploy】
第二步:安装WebDriverAgent(WDA)
如果是模拟器测试,不需要安装WDA,如果用真机一定要安装WDA
第三步:配置启动Desired Capabilities
注意项:
1.app或bundid使用一个即可
app:使用安装包的绝对路径(app或ipa的绝对路径),
bundId:如果已安装app可以使用bundlId免去安装(com.wuba.zhuanzhuan等)
2.automationName使用XCUITest
3.新增xcodeOrgId,为打包时选择的Development Team
4.新增xcodeSigningId,为打包时证书的名字
(证书名字和Team名称,可以在打包选择签名和Team的地方点击展开证书列表,选择other时输入框内的即为当前选择的team或证书名)
5.udid:标识手机唯一标识。如果只插了一个手机可以用auto,会自动匹配到唯一的设备
{ "platformName": "ios", "platformVersion": "9.3", "bundleId": "com.wuba.zhuanzhuan", "app": "/Users/a58/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/zhuanzhuan.app", "deviceName": "ZhuanZhuan", "automationName": "XCUITest", "udid": "c957fb5ec67c9d4568fdb206a4cb8f65b823896f", "xcodeOrgId": "xxx", "xcodeSigningId": “xxx" }
然后Start Session能够打开Inspector页面即表示配置成功(GUI Appium界面的操作详见另一篇随笔:http://www.cnblogs.com/meitian/p/7360055.html)
官方给出的一些日志文件地址,不用时可以进行删除
$HOME/Library/Logs/CoreSimulator/*
$HOME/Library/Developer/Xcode/DerivedData/*
Start Session时遇到的问题如下:
问题1:
An unknown server-side error occurred while processing the command. Original error: Could not create simulator with name 'appiumTest-55a8ede2-1b12-41ac-a37a-41d992a58bd0', device type id 'c957fb5ec67c9d4568fdb206a4cb8f65b823896f' and runtime id '9.3'. Reason: 'simctl error running 'create': Invalid device type: c957fb5ec67c9d4568fdb206a4cb8f65b823896f'
解决方法:
Appium1.6也必须设置udid,在启动的Desired Capabilities增加udid
问题2:
Error An unknown server-side error occurred while processing the command. Original error: Could not install app: 'Command 'ios-deploy --id c957fb5ec67c9d4568fdb206a4cb8f65b823896f --uninstall --bundle /Users/a58/Library/Developer/Xcode/DerivedData/Build/Products/Release-iphoneos/zhuanzhuan.app' exited with code 253'
解决方法:
将启动Desired Capabilities中的app路径换为Debug包的地址,不要使用Release的地址
问题3:使用模拟器,appium 启动模拟器的session
An unknown server-side error occurred while processing the command. Original error: Command 'open -Fn '/Applications/Xcode 2.app/Contents/Developer/Applications/Simulator.app' --args -CurrentDeviceUDID 2D0F53CD-ECE6-4BBC-8062-3DD0A76111FE' exited with code 1
解决方法:
重新启动appium server,然后再启动start new session
原因:
我电脑上有Xcode8和Xcode7两个版本,曾今切换到Xcode7过,然后后来又切换回Xcode8了,然后把Xcode7删除了。
但是Appium这里没更新地址,启动的仍然是旧地址Xcode2.app。所以重启一下就生效了
问题4:start new session时安装app失败(code=22)
[MJSONWP] Encountered internal error running command: Error: simctl error running 'install': An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22): Failed to install the requested application
解决方法:
Desired Capabilities 的app传递Debug包地址,例如:~/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos
原因:
Appium不支持release包,只支持debug包
问题5:启动时xcodebuild失败,code=65
An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
解决方法:编译安装WebDriverAgent
具体操作步骤详见第二步
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
2015-08-14 Django1.8:403错误:CSRF verification failed. Request aborted.
2015-08-14 django重定向
2015-08-14 django通过url传递参数(编辑操作页面)
2015-08-14 django提交post请求
2015-08-14 视图的URL配置,找不到我设置的第一个Page
2015-08-14 django1.8模板位置的设置setting.py
2015-08-14 django创建工程,用命令