iOS 自动化测试之 WDA & Appium
source link: https://kingcos.me/posts/2019/ios_test_automation/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
iOS 自动化测试之 WDA & Appium
2021.06.16 by kingcosPreface · 序
iOS 自动化测试从 0 到 1。
WebDriverAgent
为了能够非接触地远程控制与测试 iOS app,Facebook 基于 XCTest 框架开发了 WebDriverAgent(简称 WDA),但由于其内部正在转向使用 IDB(iOS Development Bridge),目前官方已经将该项目归档(如下图)。而 Appium 仍然基于 WDA 进行自动化测试,因此其也将 WDA 从 Facebook 手中接力并继续迭代。
因 Appium 的 WDA 开源版本目前下载后可以直接正常运行,且目前团队内仍使用 Facebook 版本,因此本文仍以后者为例。
安装 Carthage:
brew install carthage
安装依赖:
./Scripts/bootstrap.sh
打开 WebDriverAgent.xcodeproj
,选择 WebDriverAgentLib,并使用「Command + B」编译:
编译后,我们将 Scheme 改为 WebDriverAgentRunner,并使用「Command + U」执行测试(注意 ⚠️:真机运行时需要配置证书):
有时通过网络连接会受很多限制或速度较慢,我们也可以将电脑本机端口映射到 USB 连接的手机端口:
brew install usbmuxd
iproxy 8100 8100
此时通过 http://localhost:8100/status 即可测试端口是否映射成功:
{
"value" : {
"state" : "success",
"os" : {
"name" : "iOS",
"version" : "12.0.1"
},
"ios" : {
"simulatorVersion" : "12.0.1",
"ip" : "164.20.130.96"
},
"build" : {
"time" : "Sep 20 2019 20:43:27"
}
},
"sessionId" : "C1A52844-D32F-43F7-91C7-ADC6B3BF5BD4",
"status" : 0
}
Appium
Appium 可以使用 npm 来安装,而 npm 可以使用 Homebrew 来安装(如果 npm 速度过慢,可以使用 cnpm):
brew install npm
npm install appium -g
appium
启动后崩溃
尝试按照 https://github.com/appium/WebDriverAgent/pull/286/files 修改即可。
Xcode 12 编译失败问题
- 在 Xcode - File - Project Settings… 中,将 Build System 构建系统切换为 Legacy Build System;
- 修改错误的内存语义声明:
// 修改前:
@property (nonatomic, assign, readonly) HTTPConnection *connection;
// 修改后:
@property (nonatomic, strong, readonly) HTTPConnection *connection;
Reference
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK