因为,安卓系统依赖JAVA环境,所以这项是必需的。
JAVA SE 8u201
https://www.oracle.com/technetwork/cn/java/javase/downloads/index.html
或直接复制这个链接下载
jdk-8u201-windows-i586.exe
1.3.1打开下载地址后,点击下载页面的入口,如下图所示。
1.3.2 JDK的下载界面如下图所示。点击“Accept License Agreement”同意证书许可。
1.3.3 根据自己的操作系统情况选择对应的安装包。楼主的是32位的Windows,所以选择如下:
或直接复制这个链接下载
jdk-8u201-windows-i586.exe
1.4.1 安装JDK的操作比较简单,启动安装程序后,一律点击“下一步”即可,直至出现下图则表示安装完毕。
1.4.2 验证安装是否成功:打开cmd命令窗口,输入"java -version",检查是否正常显示java版本信息。成功安装的回显信息如下图:
1.4.2 配置JAVA的环境变量
作用:通俗的讲,配置了环境变量就好比告诉了计算机你的程序在哪个目录,以后我不管在哪个目录使用指令调用该程序都得照办。
配置方法:
1.4.2.1 在桌面的“计算机”上点击右键,选择“属性”菜单。
1.4.2.3 在底部“系统变量”栏目中,点击“新建(w)”按钮,新建一个名为“JAVA_HOME”的系统变量,值为jdk的安装根目录。例如,默认的安装目录是“C:\Program Files\Java\jdk1.8.0_201”。然后点击“确定”。
1.4.2.4 在系统变量栏目中找到一项名为“Path”的变量进行选中,点击“编辑”按钮。然后在变量值末尾追加“;%JAVA_HOME%\bin”。切记,两个变量值之间一定要以英文半角的分号相隔。最后点击“确定”按钮。
至此,JDK的安装就完成了。
推荐版本:android-sdk_r24.4.1
下载地址:http://www.android-studio.org/
网盘下载
http://pan.baidu.com/s/1kVOvxEB
下载可执行的EXE程序,或者打包好的安装包,两种方式都可以。以下以ZIP格式的解压包方式为例。
2.2 启动 SDK Manager ,下载测试设备所对应版本的安卓系统API。
解压至”D:\SDK\android-sdk-windows“
分别勾选所需要的组件,以下是楼主推荐方案,具体可根据个人需要进行选择。
选择所需的安装项后,点击“install XX packages”,其中XX代表已经勾选的项目数量。在选择安装的界面,一律勾选“Accept License”选项。最后点击“install”执行安装。
备注:联网安装,时长与网络环境有关,耐心等待。我去上个厕所
大体步骤和上文中的配置JDK的环境变量类似,这里就不再一一赘述,只说明下需要配置的参数。
2.3.1 首先,确定sdk的根目录。如下图所示,则根目录为“D:\SDK\android-sdk-windows”。其中有两个非常重要的目录,分别是tools和platform-tools.
2.3.2 在“环境变量”操作面板中,新建一个名为“ANDROID_HOME”的变量,值为SDK的根目录。如下图所示。
2.3.3 编辑系统变量Path项的值,在末尾追加两个新值,分别是“%ANDROID_HOME%\tools”和“%ANDROID_HOME%\platform-tools”。编辑完毕后点击“确定”。
;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
2.3.4 验证安卓SDK环境。打开cmd命令窗口,输入 adb version 指令,如果打印了下图信息则表示环境变量配置成功。
C:\Users\Carlson>adb version
Android Debug Bridge version 1.0.40
Version 28.0.2-5303910
Installed as D:\SDK\android-sdk-windows\platform-tools\adb.exe
用来提供Appium服务端所依赖的运行环境,因为毕竟Appium服务端就是用node.js编写的,没它玩不转。
3.1 当前版本:V0.10.32
Appium: v1.4.13 (GUI版本,桌面形式)
node.js: V0.10.32
本次我由于安装的是Appium: v1.4.13,(支持V0.12以下的Node)故暂时使用的是这个V0.10.32版本的Node.js
3.2 官网下载地址:https://nodejs.org/zh-cn/
一定要注意appium版本和node.js版本的匹配问题
否则在cmd中执行appium命令会报错
匹配的版本:
Appium: v1.4.16 (GUI版本,桌面形式)
node.js: v5.6.0
请根据自己实际情况选择版本
node-v0.10.32-x86.msi
node-v0.10.32-x64.msi
node-v5.6.0-x86.msi
node-v5.6.0-x64.msi
node-v10.15.3-x86.msi(可配合appium-desktop-setup-1.11.0.exe)
3.3 安装方法:一路点“next”,遇到“accept”点了即可。
3.4 安装完毕后,需要把node.exe程序所在的目录添加到系统环境变量,操作步骤参见JDK和SDK的配置方法。简而言之,找到node.exe程序所在目录,例如在“D:\Programs\NodeJS”,那么添加系统变量“NODE_HOME”,值为“D:\Programs\NodeJS”,然后在系统变量Path的值末尾追加“%NODE_HOME%”即可。
3.5 检查环境配置是否成功。在电脑任意目录打开cmd,输入 node -v 指令,如果打印以下结果则表示程序安装OK,且环境变量配置成功。
C:\Users\Carlson>node -v
v0.10.32
desktop版本
Github工程地址: https://github.com/appium/appium-desktop/releases
属于新的桌面形式的appium版本,有界面,可以配置各项参数,可以启动inspect查看手机界面元素;不管是win还是mac下目前都支持简单的录制操作,appium desktop的版本和appium的版本并不是一一对应,下载地址
https://github.com/appium/appium-desktop/releases/
GUI版本,桌面形式
下载安装地址: https://bitbucket.org/appium/appium.app/downloads
win上更新到了1.4.16(不支持录制),mac上更新到了1.5.x(支持录制),目前均不再维护,GUI版本跟appium版本一一对应
点如下链接直接下载
AppiumForWindows_1_4_16_1.zip
AppiumForWindows_1_4_13_1.zip
注:我这次装的是1.4.13.1 (AppiumForWindows_1_4_13_1)
appium 命令行版本
不管是win还是mac,安装这种形式的就没有界面,安装方式都是npm -g install appium,默认会安装当前最新版本
通常我们说你的appium服务端版本是多少,指的是在命令行下的appium版本
一定要注意appium版本和node.js版本的匹配问题
否则在cmd中执行appium命令会报错
匹配的版本:
Appium: v1.4.16
node.js: v5.6.0 s
直接双击appium-installer.exe文件安装就好,桌面会生成一个appium的图标,启动后界面显示如下
检查当前系统的Appium环境依赖是否都已齐备
使用appium-doctor程序,可以快速全面检测当前系统中所依赖资源的安装情况,一目了然。
5.1 appium安装好后,找到这个文件目录"C:\Program Files\Appium\node_modules.bin"
5.2 将上面的地址添加到环境变量path下
;C:\Program Files\Appium\node_modules\.bin
打开cmd,输入appium-doctor,检查环境是否OK,出现如下图所示,说明环境OK
在C:\Program Files\Appium\node_modules\appium\lib\server下配置修改”capabilities.js“与”parser.js“
parser.js
106行修改为
defaultValue: true
529行修改为
defaultValue: 14400
619行插入
[['--unicode-Keyboard'], {
dest: 'unicodeKeyboard'
, defaultValue: true
, action: 'storeTrue'
, required: false
, help: "Android for set unicodeKeyboard"
}],
[['--reset-Keyboard'], {
dest: 'resetKeyboard'
, defaultValue: true
, action: 'storeTrue'
, required: false
, help: "Android for set resetKeyboard"
}],
在C:\Program Files\Appium\node_modules\appium\lib\devices\android下的android.js的112,113,114,117行注释掉
//是注释
关掉自动升级、自动unlock的功能
关于启动Appium
通过cmd命令的方式启动appium,一定要注意appium版本和node.js版本的匹配问题
appium ,用默认的方式启动appium
appium -a 127.0.0.1 -p 4729 -bp 4730
-a 是指定监听的ip
-p 是指定监听的端口
-bp 是连接Android设备bootstrap的端口号,默认是472
参考文档:
Cmd 启动Appium - 雨水的早晨的博客 - CSDN博客
1.1 当前版本:V3.6.2
1.2 官网下载地址:https://www.python.org/
如下选择,然后一路Next
ps:因安装时忘记截图保存了,此处使用Python3.7的图
1.3 检查安装是否成功
打开cmd命令窗口,输入指令: python ,如果成功安装则会打印如下信息
C:\Users\Carlson>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
1.4 更新pip
输入python -m pip install --upgrade pip升级pip
C:\Users\Carlson>python -m pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828d
fc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
34% |███████████▏ | 471kB 1.1MB/s eta 0:00:01
100% |████████████████████████████████| 1.4M
B 556kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-19.0.3
C:\Users\Carlson>
当前版本:Appium-Python-Client-0.40.tar.gz
selenium版本:selenium-3.141.0-py2.py3-none-any.whl
urllib3版本:urllib3-1.24.1-py2.py3-none-any.whl
在cmd命令窗口中执行pip命令即可: pip install Appium-Python-Client
C:\Users\Carlson>pip install Appium-Python-Client
Collecting Appium-Python-Client
Downloading https://files.pythonhosted.org/packages/26/f1/f932791ec73be6e13539
fb201f6923305b8e67b2b47078fd2efc3ad4f865/Appium-Python-Client-0.40.tar.gz (41kB)
100% |████████████████████████████████| 51kB
511kB/s
Collecting selenium>=3.14.1 (from Appium-Python-Client)
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13
e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl (
904kB)
100% |████████████████████████████████| 911k
B 324kB/s
Collecting urllib3 (from selenium>=3.14.1->Appium-Python-Client)
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d
1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (11
8kB)
100% |████████████████████████████████| 122k
B 342kB/s
Installing collected packages: urllib3, selenium, Appium-Python-Client
Running setup.py install for Appium-Python-Client ... done
Successfully installed Appium-Python-Client-0.40 selenium-3.141.0 urllib3-1.24.1
如果打印结果中显示“Successfully installed Appium-Python-Client-0.40”则表明安装成功。
这里列出在安装
ride时候需要用到的库
安装requests库: pip install requests
安装robotframework: pip install robotframework
安装wxPython: pip install wxPython
安装pywin32: pip install pywin32
安装pygments: pip install pygments
安装ride: pip install robotframework-ride
推荐使用pip安装,如 pip install robotframework(以及selenium2library)
pip install requests
我安装的是 requests-2.21.0
依赖包:
requests-2.21.0-py2.py3-none-any.whl
idna-2.8-py2.py3-none-any.whl
certifi-2019.3.9-py2.py3-none-any.whl
chardet-3.0.4-py2.py3-none-any.whl
C:\Users\Carlson>pip install requests
Collecting requests
Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353
c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests)
Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1
cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e
03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\python36-32\lib\site-
packages (from requests) (1.24.1)
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b64
87b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: idna, certifi, chardet, requests
Successfully installed certifi-2019.3.9 chardet-3.0.4 idna-2.8 requests-2.21.0
pip install robotframework
我安装的是robotframework-3.1.1
robotframework-3.1.1-py2.py3-none-any.whl
C:\Users\Carlson>pip install robotframework
Collecting robotframework
Using cached https://files.pythonhosted.org/packages/36/c6/6f89c80ac5a526a091b
d383ffdfc64c9a68d9df0c775d4b36f03d8e0ac25/robotframework-3.1.1-py2.py3-none-any.
whl
Installing collected packages: robotframework
Successfully installed robotframework-3.1.1
若想安装RIDE(界面编辑工具)需安装:
pip install wxPython
我安装的是wxPython4.0.4
Collecting six (from wxPython)
Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe
898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: Pillow, six, wxPython
Successfully installed Pillow-5.4.1 six-1.12.0 wxPython-4.0.4
pip install pywin32
我安装的是pywin32-224
Installing collected packages: pywin32
Successfully installed pywin32-224
使用pygments高亮代码
pip install pygments
我安装的是pygments-2.3.1
Pygments-2.3.1-py2.py3-none-any.whl
C:\Users\Carlson>pip install pygments
Collecting pygments
Using cached https://files.pythonhosted.org/packages/13/e5/6d710c9cf96c31ac826
57bcfb441df328b22df8564d58d0c4cd62612674c/Pygments-2.3.1-py2.py3-none-any.whl
Installing collected packages: pygments
Successfully installed pygments-2.3.1
参考文档:
Python编程:使用pygments高亮代码
使用Pygments来实现代码高亮
pip install -U robotframework-requests
我安装的是robotframework-requests-0.5.0
robotframework-requests-0.5.0.tar.gz
C:\Users\Carlson>pip install robotframework-requests
Collecting robotframework-requests
Using cached https://files.pythonhosted.org/packages/ca/72/cc94e0de0bc9d38d33f
7133a233089d9b1be17345d609af2bb54a3fff932/robotframework-requests-0.5.0.tar.gz
Requirement already satisfied: robotframework in c:\python36-32\lib\site-package
s (from robotframework-requests) (3.1.1)
Requirement already satisfied: requests in c:\python36-32\lib\site-packages (fro
m robotframework-requests) (2.21.0)
Requirement already satisfied: idna<2.9,>=2.5 in c:\python36-32\lib\site-package
s (from requests->robotframework-requests) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\python36-32\lib\site-
packages (from requests->robotframework-requests) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\python36-32\lib\site-pac
kages (from requests->robotframework-requests) (2019.3.9)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\python36-32\lib\site-
packages (from requests->robotframework-requests) (3.0.4)
Installing collected packages: robotframework-requests
Running setup.py install for robotframework-requests ... done
Successfully installed robotframework-requests-0.5.0
这个具体什么用,requests和robotframework-requests的区别后续再研究
robotFramework-Requests、RequestsLibrary接口测试
pip install robotframework-appiumlibrary
我安装的是robotframework-appiumlibrary
使用setup.py安装
git clone https://github.com/jollychang/robotframework-appiumlibrary.git
cd robotframework-appiumlibrary
python setup.py install
使用pip安装
pip install robotframework-appiumlibrary
版本:robotframework-appiumlibrary-1.5.0.2.tar.gz
decorator-4.4.0-py2.py3-none-any.whl
docutils-0.14-py3-none-any.whl
kitchen-1.2.5.tar.gz
C:\Users\Carlson>pip install robotframework-appiumlibrary
Collecting robotframework-appiumlibrary
Downloading https://files.pythonhosted.org/packages/21/dc/1221e56dcb1759d97460
290199ae5df3fcc6a7e1f41bf7bf8e50fcc11bb4/robotframework-appiumlibrary-1.5.0.2.ta
r.gz
Collecting decorator>=3.3.2 (from robotframework-appiumlibrary)
Downloading https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0d
cbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Requirement already satisfied: robotframework>=2.6.0 in c:\python36-32\lib\site-
packages (from robotframework-appiumlibrary) (3.1.1)
Collecting docutils>=0.8.1 (from robotframework-appiumlibrary)
Downloading https://files.pythonhosted.org/packages/36/fa/08e9e6e0e3cbd1d362c3
bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)
100% |████████████████████████████████| 552k
B 3.7MB/s
Requirement already satisfied: Appium-Python-Client>=0.28 in c:\python36-32\lib\
site-packages (from robotframework-appiumlibrary) (0.40)
Requirement already satisfied: selenium>=2.47.1 in c:\python36-32\lib\site-packa
ges (from robotframework-appiumlibrary) (3.141.0)
Collecting kitchen>=1.2.4 (from robotframework-appiumlibrary)
Downloading https://files.pythonhosted.org/packages/14/3c/eb027400d34ed066d882
d4cbbcb9b84eb7e91a7be770dd6fecebc37ba91f/kitchen-1.2.5.tar.gz (255kB)
100% |████████████████████████████████| 256k
B 1.5MB/s
Requirement already satisfied: six>=1.10.0 in c:\python36-32\lib\site-packages (
from robotframework-appiumlibrary) (1.12.0)
Requirement already satisfied: urllib3 in c:\python36-32\lib\site-packages (from
selenium>=2.47.1->robotframework-appiumlibrary) (1.24.1)
Installing collected packages: decorator, docutils, kitchen, robotframework-appi
umlibrary
Running setup.py install for kitchen ... done
Running setup.py install for robotframework-appiumlibrary ... done
Successfully installed decorator-4.4.0 docutils-0.14 kitchen-1.2.5 robotframewor
k-appiumlibrary-1.5.0.2
配置:
C:\Python36-32\Lib\site-packages\AppiumLibrary\keywords目录下的_element.py文件
中在521行处改为
if self._get_platform() in platform_class_dict:
return True
else:
return False
#return platform_class_dict.has_key(self._get_platform())
参考文档:
RobotFramework自动化测试框架-移动手机自动化测试AppiumLibrary介绍
pip install robotframework-ride
我安装的是robotframework-ride-3.1.1
robotframework_ride-1.7.3.1-py2.py3-none-any.whl
C:\Users\Carlson>pip install robotframework-ride
Collecting robotframework-ride
Using cached https://files.pythonhosted.org/packages/4e/a6/1835a17fa566b19c166
735a9a75d55101e53b68566771ddb0b690dd4be83/robotframework_ride-1.7.3.1-py2.py3-no
ne-any.whl
Requirement already satisfied: robotframework in c:\python36-32\lib\site-package
s (from robotframework-ride) (3.1.1)
Collecting robotframeworklexer (from robotframework-ride)
Using cached https://files.pythonhosted.org/packages/24/18/ad01d42227d824b890f
1b4d32237e5003bf7afe8764cb13545fb63d7fcb5/robotframeworklexer-1.1-py3-none-any.w
hl
Collecting Pypubsub (from robotframework-ride)
Downloading https://files.pythonhosted.org/packages/1a/41/a0aceb552d8ec63bb1e8
223d130f9dd0f736470036d75d708183b104a2cb/Pypubsub-4.0.3-py3-none-any.whl (61kB)
50% |████████████████ | 30kB 472kB/s eta 0:00
66% |█████████████████████▌ | 40kB 319kB/s et
83% |███████████████████████████ | 51kB 390kB
100% |████████████████████████████████| 61kB
415kB/s
Requirement already satisfied: Pygments in c:\python36-32\lib\site-packages (fro
m robotframework-ride) (2.3.1)
Requirement already satisfied: wxPython in c:\python36-32\lib\site-packages (fro
m robotframework-ride) (4.0.4)
Requirement already satisfied: Pywin32 in c:\python36-32\lib\site-packages (from
robotframework-ride) (224)
Requirement already satisfied: six in c:\python36-32\lib\site-packages (from wxP
ython->robotframework-ride) (1.12.0)
Requirement already satisfied: Pillow in c:\python36-32\lib\site-packages (from
wxPython->robotframework-ride) (5.4.1)
robotframework-ride 1.7.3.1 has requirement Pypubsub==3.3.0, but you'll have pyp
ubsub 4.0.3 which is incompatible.
Installing collected packages: robotframeworklexer, Pypubsub, robotframework-rid
e
Successfully installed Pypubsub-4.0.3 robotframework-ride-1.7.3.1 robotframework
lexer-1.1
安装完成后,在命令行输入 ride就可以直接启动RIDE窗口了
RIDE是一款专门用来编辑Robot Framework用例的软件,用Python编写并且开源
传送门RIDE使用介绍
启动RIDE
的cmd窗口中输入ride运行即可
RIDE中的路径有中文乱码,后续研究
适合编辑Python脚本的IDE工具有很多,以下2种各位可以自由选择
参照链接
Sublime Text3安装以及初次配置
下载安装sublime后 为了让其能够 Robot Framework语法高亮 (Robot Framework syntax lignlighting )
选择Preferences-Package Control,然后输入install package(这里要等一会才能出现)
在弹出的窗口的输入“robot”就能找到 robot framework assistant,并进行选择,之后就能安装成功。
这样就可以在view-syntax中找到“robot framework syntax highlight”
个人觉得Pycharm的community社区版基本够用了。
当前版本:pycharm-community-2018.3.5
官网下载地址:http://www.jetbrains.com/pycharm/download/#section=windows
点我下载 pycharm-community-2018.3.5.exe
安装方法:可以佛系,启动安装程序后,一路点下一步即可。
Pycharm的安装与汉化 - jia666666的博客 - CSDN博客
1.1 开启USB调试
在跑脚本之前,一定要先开启USB调试
或是通过局域网连接,一定要先开启调试模式,配置好相应的设备端与PC端IP
1.2 检查设备连接情况
打开cmd命令窗口,输入指令: adb devices ,设备成功连接的打印信息如下:
C:\Users\Administrator>adb devices
List of devices attached
127.0.0.1:21503 device
其中,“127.0.0.1:21503”为设备的udid编号,“device”表示设备状态是已连接。如果设备列表为空,或者设备状态是“offline”,则是连接失败的情况,需要具体排查产生的原s因。
至此,Appium大门已经向你敞开啦,可以愉快地玩耍啦~~~
参考文档:
Appium-Python-Windows环境搭建笔记 - Cifer_Woods - 博客园