【Appium】基于 Appium 的 iOS 自动化
基于 Appium 的 iOS 自动化
- 一、Appium 环境搭建(macOS 10.15)
- 1、安装 Appium-server
- 2、替换并配置 WebDriverAgent
- 3、安装 [Appium-Client](http://appium.io/docs/en/about-appium/appium-clients/)
- 4、启动自动化环境
- 二、iOS UI自动化简述
- 1、UI自动化会做什么?
- 2、iOS 怎么做UI自动化?(基于Appium)
- 三、基于页面滑动的自动化实践
- 1、UI脚本思路
- 2、UI脚本实现(基于Appium + WebDriverAgent)
- 参考文档
一、Appium 环境搭建(macOS 10.15)
1、安装 Appium-server
(1) 安装 node.js
方法1:brew install node
方法2:下载pkg文件安装( 推荐)
检查是否安装成功:
➜ /Users
node -v
v12.11.1
➜ /Users
npm -v
6.14.7
(2)安装 appium
➜ /Users
npm install -g appium
2、替换并配置 WebDriverAgent
(1)GitHub 下载 WebDriverAgent
(2)替换本地 Appium-server 下的 WebDriverAgent
Appium-server 下 WebDriverAgent 路径:
/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent
(3) 配置 WebDriverAgent → 查看 详细配置教程
3、安装 Appium-Client
Python https://github.com/appium/python-client
Java https://github.com/appium/java-client
4、启动自动化环境
(1)启动 Appium (→ 完整参数说明)
appium --session-override --relaxed-security --log-timestamp -g appium.txt
(2)启动 WebDriverAgent (→ 参考 详细配置教程-配置部分)
Xcode - WebDriverAgent - product - test
二、iOS UI自动化简述
1、UI自动化会做什么?
- 元素定位
- 元素操作
- 校验
2、iOS 怎么做UI自动化?(基于Appium)
(1)怎么安装包?
ideviceinstaller
- 安装 ipa 包
ideviceinstaller -i xxx.ipa
- 卸载应用
ideviceinstaller -U [bundleID]
- 查看设备安装了哪些应用
➜ /Users
ideviceinstaller -l
com.ss.iphone.ugc.Aweme, “132010”, “抖音”
com.apple.TestFlight, “37”, “TestFlight”
com.kkmh.WebDriverAgentRunner.xctrunner, “1”, “WebDriverAgentRunner-Runner”
com.tencent.ied.app.comic, “12054”, “腾讯动漫”
com.tencent.mttlite, “8.9.1.4014”, “QQ浏览器”
libimobiledevice
- 查看设备udid
➜ /Users
> idevice_id -l
7d65ad26a4e27ce38adda4d7a794cf1bfc08c9b7
- 把设备里的崩溃日志都取出来
idevicecrashreport -u 7d65ad26a4e27ce38adda4d7a794cf1bfc08c9b7 -e -k ~/Downloads/temp
Copy: /periodic-io-microstackshot-report-2020-10-16-154441.ips
Copy: /mttlite-2020-10-21-132243.ips
Copy: /LowBatteryLog-2020-10-07-182630.ips
Copy: /periodic-microstackshot-report-2020-10-30-092621.ips
Copy: /stacks+routined-2020-10-12-151256.ips
Copy: /JetsamEvent-2020-09-23-104111.ips
Copy: /mttlite-2020-10-21-135024.ips
Copy: /Analytics-2020-09-23-080316.ips.ca
Copy: /JetsamEvent-2020-09-28-070134.ips
Copy: /JetsamEvent-2020-09-23-164411.ips
Copy: /periodic-io-microstackshot-report-2020-10-27-152037.ips
Copy: /stacks+routined-2020-10-30-185706.ips
Done.
(2)怎么启动应用?怎么定位元素?怎么操作元素?
通过 WebDriverAgent 实现。
WebDriverAgent is a WebDriver server implementation for iOS that can be used to remote control iOS devices.
It allows you to launch & kill applications, tap & scroll views or confirm view presence on a screen.
WebDriverAgent 基于 XCTest ,那 XCTest 实现了什么:
- class XCUIApplication → 启动应用、结束应用
- class XCUIElementQuery → 查询元素
- protocol XCUIElementAttributes → 暴露UI元素属性
- class XCUIElement → 查询元素状态、输入、点击、双击、滑动、两指操作等
- class XCUIDevice → 模拟物理按键,设备方向,siri交互
三、基于页面滑动的自动化实践
自动化实践:列表页不断上滑,验证页面稳定性
1、UI脚本思路
- 操作:进入列表页,不断进行上滑操作
- UI脚本缺点:查询控件慢
- 解决:去掉通过脚本查询控件,换成手动点开列表页;之后再由UI脚本进行滑动操作。
2、UI脚本实现(基于Appium + WebDriverAgent)
- 手动点击进入列表页(主要增加手动操作时间,直接写了 20s)
import time
time.sleep(20)
- 实现向上滑动功能
def swipe(self):telPa = Appium.getDriver().get_window_size()self.width = telPa["width"]self.height = telPa["height"]x1=int(self.width * 1/2)y1=int(self.height * 3/4)y2=int(self.height * 1/4)Appium.getDriver().swipe(x1, y1, x1, y2, 100)
- 使用滑动功能
t = 0
while t< 100000:self.swipe()t+=1print("现在t的值是:"+str(t))
参考文档
Appium文档:https://github.com/appium/appium/tree/master/docs
WebDriverAgent:https://github.com/facebookarchive/WebDriverAgent
XCTest:https://developer.apple.com/documentation/xctest
libimobiledevice:https://github.com/libimobiledevice/libimobiledevice
ideviceinstaller:https://github.com/libimobiledevice/ideviceinstaller
【Appium】基于 Appium 的 iOS 自动化相关推荐
- App 自动化解决方案 [开源项目] 基于 Appium 的 UI 自动化测试框架完美版
欢迎查阅Appium(Android自动化测试框架体系) Appium Appium是一个移动端的自动化框架,可用于测试原生应用,移动网页应用和混合型应用,且是跨平台的,可用于IOS和Android以 ...
- 【appium】appium自动化入门之ios软件如何测试
上篇文章写到appium在Mac上的环境搭建,这篇进入正文,如何在Mac端的appium上测试你的ios产品 app端的文章如下: 第一类:[appium]appium自动化入门之环境搭建(上) 第二 ...
- iOS自动化测试之Appium的安装和使用
一.前言 因为需要配合测试同学处理自动化测试方面的东西,所以记录下来自己关于Appium的安装和使用,但是主要是关于安装的,因为安装真是遇到了很多坑,另外,我只是关注iOS App的测试,所以这里没有 ...
- 基于Appium+JAVA环境测试iOS
至于原理什么的,这里不再阐述,网上有很多讲述原理的例子相信你们已有所了解,你想用JAVA环境来测试iOS,那么我想你一定是有些想法的,来吧We Go MacOSX上搭建Appium-iOS环境所需的软 ...
- 基于Appium+Pytest的UI自动化实例(Android)
基于Python3 Appium+Pytest的UI自动化实例(Android) 春有百花秋有月,夏有凉风冬有雪 若无闲事挂心头,便是人间好时节 第一部分:所需环境的配置 所需软件网盘链接(提取码19 ...
- 基于Appium+WinAppDriver+Python的winUI3应用的自动化框架搭建分享(一)环境配置
安装WinAppDriver 下载并安装WinAppDriver:来源 https://github.com/Microsoft/WinAppDriver/releases 开启电脑的开发者模式 设置 ...
- [Appium] 搭建Android App UI自动化环境
[Appium] 搭建Android App UI自动化环境-Windows10 一.Appium介绍 Appium是一个开源的自动化测试工具,其支持iOS和安卓平台上的原生的,基于移动浏览器的,混合 ...
- 基于Appium的移动端UI自动化测试
为什么需要UI自动化测试 移动端APP是一个复杂的系统,不同功能之间耦合性很强,很难仅通过单元测试保障整体功能.UI测试是移动应用开发中重要的一环,但是执行速度较慢,有很多重复工作量,为了减少这些工作 ...
- Pycharm中用Appium框架编写第一个自动化脚本
一.环境依赖 ·Node.js ·appium ·python ·jdk ·Android SDK ·Appium-Python-Client ·Appium-doctor 二.环境搭建 提醒:安装路 ...
最新文章
- spring session 退出登录 清理session
- WEB项目中的中文乱码问题
- ie浏览器 杂项样式错乱
- H264参数语法文档: SPS、PPS、IDR
- 西门子主程序调用子程序_S7200Smart 子程序局部变量使用教程
- c++面向对象高级编程 学习十五 组合继承关系下的构造和析构
- SHELL编程传递参数方法详解$# $* $0 $1 $2 $...
- [转载] Python模块
- 酒店IPTV数字电视系统解决方案
- 串级调节系统参数整定方法(串级调节器参数整定)
- ​Copyright到底是什么意思?
- scrapy 报错401
- python爬取网页的内层页_python爬取网页 下一页
- Craw the data of the web page and parse to pdf
- 在最美的时候,你遇见了谁?
- 如何获取腾讯视频的MP4播放地址及mp4文件,无需进行qlv转换mp4格式【亲测效果】
- IP,ARP,以太网--网络层与数据链路层详解
- charles基础使用
- k8s pod基础概念
- 堡垒机,ssh协议,telnet协议,b/s架构