npm install -g appium-doctor
装好以后运行一下
appium-doctor
info AppiumDoctor Appium Doctor v.1.6.0
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ✔ The Node.js binary was found at: C:\Program Files\nodejs\node.exe
info AppiumDoctor ✔ Node version is 10.14.1
info AppiumDoctor ✔ ANDROID_HOME is set to: D:\Android-SDK
info AppiumDoctor ✔ JAVA_HOME is set to: C:\Program Files\Java\jdk1.8.0_171\bin
info AppiumDoctor ✔ adb exists at: D:\Android-SDK\platform-tools\adb.exe
info AppiumDoctor ✔ android exists at: D:\Android-SDK\tools\android.bat
info AppiumDoctor ✔ emulator exists at: D:\Android-SDK\tools\emulator.exe
info AppiumDoctor ✔ Bin directory of %JAVA_HOME% is set
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor
工具会帮你看是否环境都配好了
pip install Appium-Python-Clinet
Collecting Appium-Python-Clinet
Could not find a version that satisfies the requirement Appium-Python-Clinet (from versions: )
No matching distribution found for Appium-Python-Clinet
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
可能会给出一些提示,按照提示更新就好
python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 14kB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
(注意:此处可能要,姿势请自己解决,推荐lantern就搞定了)
把Appuim-Python-Client装好以后,环境配置基本上就完成了
多啰嗦一句
我们首先要理解一下,其实Appuim是一个C/S框架的运行的东东,步骤1 只是开了一个Server,它提供服务(与Android手机链接并执行用例的任务balabala),所以我们真正需要做的是写Client的逻辑,而连接CS之间靠什么,就靠我们下载下来的Appuim-Python-Client,当然你要乐意用java写也可以用Appium-Java-Client,这就是为什么Appium能支持多语言编写用例了,其实Appium本质是nodeJS,nodeJS是干啥的,你们懂的~~ 能想到这玩意的也是大牛
写个简单的连接
我们先来点难度低的,Android手机里面都有计算器,我们就尝试控制一些计算器好了
计算器的包名是com.android.calculator2, 类为Calculator
使用python unit test 框架