AppUI自动化
实质:
发送指令获取元素,计算元素坐标,自动化驱动程序根据指令对元素进行操作。
了解个平台的自动化驱动框架,挑选一款成熟,合适的框架,学习API的使用。
基础准备:
adb
UIAutomator
WebDriverAgent
Instruments
iOS自带的单元测试
常见的UI自动化测试工具:
Appium:多平台,支持多语言,开源,学习资料全
Macaca:多平台,支持JS/Python,半开源
MonkeyTalk:缺点是收费
Appium
Appium不是一个自动化驱动程序,它是一个server,指令的转发者,调度其他自动化驱动框架(UIAUTOMATOR)执行。涉及到脚本执行客户端,appium server,以及设备。
Ps:UIAUTOMATOR测试不需要源码,只需要一个apk就可以测试。
环境搭建:
1.基础环境:Android SDK,JDK
2.Appium服务端:Appium Server
3.Appium客户端:Python,Python-Client,java-client(jar,maven)
根据教程搭建appium
java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
➜ ~ git --version
git version 2.8.4 (Apple Git-73)
➜ ~ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
➜ ~ brew -v
Homebrew 1.2.0
Homebrew/homebrew-core (git revision 2d9a; last commit 2017-05-09)
➜ ~ npm -v
4.2.0
➜ ~ npm install -g appium
Ps: 卸载appium终端命令 npm uninstall appium -g
遇到的问题
1. Error: EACCES: permission denied, access '/usr/local/lib/node_modules/appium/node_modules/acorn'
2. "node@v4.4.5" is incompatible with appium-mac-driver@1.0.2 › punycode@^2.
3. info Chromedriver Install Downloading https://chromedriver.storage.googleapis.com/2.28/chromedriver_mac64.zip...
RequestError: Error: connect ETIMEDOUT 64.233.162.83:443
4. Tried too many times to install UiAutomator2, failing Original error: Error: connect ETIMEDOUT 54.231.34.41:443
5. update-linked node_modules/appium/node_modules/appium-uiautomator2-server needs updating to 0.1.4 from 0.1.5 but we can't, as it's a symlink
6. Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module 'lodash/object/assign'
7. Error: Cannot find module 'extract-zip'
8. Failed at the appium-selendroid-driver@1.6.0 install script 'node ./bin/install.js'.
第一次appium的使用
遇到的问题:
[XCUITest] Error: Sdk ‘10.1’ was not in list of simctl sdks at getDevices$
[iOS] SessionNotCreatedError: A new session could not be created. Details: Appium’s IosDriver does not support xcode version 8.0. Apple has deprecated UIAutomation. Use the “XCUITest” automationName capability instead.
解决方案:添加 一个字段 说明使用XCUITest进行自动化。