一、软件安装
安装清单:
- JDK
- Python
- node.js
- android-sdk(作者通过Android Studio安装)
- iOS-deploy
- brew
- libimobiledevice依赖库
- ideviceinstaller
- carthage依赖库
appium-doctor(安装后可在命令行中通过命令:appium-doctor检查还少啥)
- WebDriverAgent
Appium-Python-Client
软件清单:
Xcode
pycharm
Appium Inspector
Appium Server GUI
JDK、node.js、android-sdk、appium-doctor、Appium-Python-Client、Appium Server GUI
可以参考:appium环境配置(史上最全详细)_appium安装及环境配置-优快云博客
补充1:node.js作者下载方式
卸载node
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
官网下载包:
补充2:Python-Client下载
方式1:通过pip命令下载 前提:有下载了pip命令(一般下载python后都有)
可通过:pip --version命令检查
官网下载get-pip.py脚本:地址:Index of /
在命令行中,切换到get-pip.py所在的目录,然后输入以下命令进行安装:
python get-pip.py(若你下的是Python3以上命令是:python3 get-pip.py)
方式2:github下载python-client
GitHub - appium/python-client: Python language bindings for Appium
官网上有下载说明:
在pycharm中安装:
Appium Inspector官网安装地址
Releases · appium/appium-inspector · GitHub
brew、 iOS-deploy、libimobiledevice、carthage安装可以参考
2023主流技术 Appium+IOS 自动化测试环境搭建-优快云博客
WebDriverAgent(巨坑)
需要手动在官网下载代码,配置好后,局部替换Appium中的WebDriverAgent
官网地址:https://github.com/facebookarchive/WebDriverAgent
下载好后替换appium自带的webDriverAgent的里面几个文件
替换代码后配置可参考:2023主流技术 Appium+IOS 自动化测试环境搭建-优快云博客关于#AppiumInspector#的问题,如何解决?_运维-优快云问答
问题:关于ServerURLHere中间的http://IP地址:端口/status无法访问的问题。
有些国产的 iPhone 机器通过手机的 IP 和端口还不能访问,此时需要将手机的端口转发到 Mac 上。
iproxy 8100 8100
使用
iproxy --help
可以查到更具体的用法。 这时通过访问http://localhost:8100/status
确认 WDA 是否运行成功。
二. Allure安装与使用(用于生成测试报告)
生成测试报告需要下载allure包 和 allure-pytest 库, 测试报告是通过allure-pytest生成,通过本地的allure包展示测试报告
allure包下载地址
下载地址:https://github.com/allure-framework/allure2/releases
下载解压完成后,将bin文件夹所在的目录放入环境变量中,同时需要安装JDK
pycharm上安装allure
执行命令:pip install allure-pytest
或者在pycharm中点击+号搜索allure-pytest下载即可:
allure使用参考下面两篇文章
Pytest 测试框架与Allure 测试报告——Allure2测试报告-L2-优快云博客
Python生成allure测试报告,allure使用详细说明_allure报告-优快云博客
三.Anywhere安装与使用(局域网内分享Allure测试报告)
安装node.js,使用npm命令安装Anywhere
sudo npm install -g anywhere
安装成功后打开cmd命令窗口进入测试报告所在目录(index.html所在页面)
指定端口打开:
anywhere -p 9090
执行anywhere
四.使用Appium Inspector连接手机
1.启动Appium Server服务端
2.Inspector配置
Mac如何获取iOS设备信息?
1.通过shell命令
brew install libimobiledevice
idevice_id -l
2.通过Xcode
打开Xcode>连接iOS设备>Xcode选择下Window选择Devices and Simulators,选择Devices,Identifier即是
3.查看 iOS 设备日志
idevicesyslog
4.查看链接设备的UDID
idevice_id --list
5.查看设备信息
ideviceinfo
6.获取设备时间
idevicedate
7. 获取设备名称
idevicename
8. 端口转发
iproxy XXXX YYYY
9.屏幕截图
idevicescreenshot
android:
获取设备名:
adb devices
获取要测试的包名与启动页activity
aapt dump badging app-debug.apk
四.定位元素、编写python脚本
........