iOS自动化测试-使用真机进行自动化测试
1、运行iOS程序到真机
1.1 在Xcode中登录自己的Apple ID
1.2 配置开发者信息
1.3 选择将要运行的程序和设备
1.4 快捷键 command+r 运行
1.5 在手机中进入 设置-通用-设备管理-自己的Apple ID-信任程序
1.6 重新 command+r 运行
2、配置WebDriveAgent
2.1 进入到下载的WebDriveAgent项目下
2.2 输入命令
./Scripts/bootstrap.sh
2.3 启动 WebDriveAgent.xcodeproj
2.4 配置 WebDriveAgentLib 的开发者信息
2.5 配置 WebDriveAgentRunner 的开发者信息
2.6 配置 IntegrationApp 的开发者信息
2.7 修改 WebDriveAgentRunner 的 Product Bundle Identifier
2.8 修改 IntegrationApp 的 Product Bundle Identifier
2.9 数据线连接真机
2.10 选择将要运行的 WebDriveAgentRunner 和 真机设备
2.11 使用 command+u 运行
-
稍等之后会在log中出来一个url地址 在浏览器中打开这个地址,如果显示一串json数据,即为正确连接手机 并且,真机会多一个程序
2.12 将配置好的 WebDriveAgent 项目替换到 appium 的 WebDriveAgent 项目
-
打开 finder 快捷键 command+shift+g 输入路径 /Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver 回车 将旧项目换个名字,当作备份 将配置好的项目放在这个目录下
3、运行自动化脚本
3.1 编写前置代码
3.2 查看 udid 并增加为启动参数
可在 Xcode 选择 Window - Devices and Simulators - Devices - 复制 Identifier
3.3 运行即可
from appium import webdriver # 前置代码 desired_caps = dict() desired_caps[platformName] = iOS desired_caps[platformVersion] = xxx desired_caps[deviceName] = iPhone xxx desired_caps[app] = com.xxx.xxx # 真机需要使用的参数 desired_caps[udid] = xxxxxxxx deriver = webdriver.Remote(http;//localhost:4723/wd/hub, desired_caps)
