Appium系列文章1: Appium开发环境搭建

http://appium.io/slate/cn/master/?ruby#appium-概念     ---- Appium权威中文资料在此。


笔者最近开始研究Appium框架,遇到的问题当然是什么是Appium, Appium有什么作用, Appium开发环境如何搭建,Appium如何使用的问题。


本文中我记录的信息就是Appium开发环境如何搭建,目前网络上已经有了很多现成的文章,指导如何搭建Appium环境,涉及到很多的软件,比如Node, Appium, Appium Client,JDK, Maven等等,按照已经存在的Guid的步骤,就可以搭建出Appium环境。但是我个人在按照Guide搭建环境的时候有很多疑惑,比如说,该软件的作用是什么,安装该软件是否必要等等。


Appium是Client/Server架构的,那么,首先就是Appium Server如何构建:我总结应该是有两种方式:GUI的方式和Command line的方式,两种方式各有优缺点,


1)GUI方式安装Appium

OS: Mac OS X, Version: 10.9.4

1. 下载Appium GUI 安装文件: http://appium.io/, 点击“Download Appium”, 下载得到文件“Appium-1.3.7.dmg”

2. 点击Appium-1.3.7.dmg安装

3. 查看Applications目录下面,“Appium.app”已经存在,则通过GUI方式安装Appium成功

4. Launch “Appium.app”, 之后点击“Doctor”按钮,Appium会检查你的运行环境是否完全配置正确,并指导修复环境,比如我的环境检测如下:

android-eb274a48f2bbe8ed:~ autotest$ '/Applications/Appium.app/Contents/Resources/node/bin/node' '/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium-doctor.js'
Running iOS Checks
✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer
✔ Xcode Command Line Tools are installed.
✔ DevToolsSecurity is enabled.
✔ The Authorization DB is set up properly.
✔ Node binary found at /usr/local/bin/node
✔ iOS Checks were successful.

Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.

说明我的Android测试环境没有配置成功

还有一点就是,上述信息现实我的Node使用的是,“/usr/local/bin/node”, 这个是我自己安装的Node.js,自己安装Node.js是否必要呢?答案是不必要的,我做了如下验证:

sudo mv /usr/local/bin/node /usr/local/bin/node_bak

android-eb274a48f2bbe8ed:~ autotest$ '/Applications/Appium.app/Contents/Resources/node/bin/node' '/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium-doctor.js'
Running iOS Checks
✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer
✔ Xcode Command Line Tools are installed.
✔ DevToolsSecurity is enabled.
✔ The Authorization DB is set up properly.
✔ Node binary found using .appiumconfig.json at /Applications/Appium.app/Contents/Resources/node/bin/node
✔ iOS Checks were successful.

Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.
android-eb274a48f2bbe8ed:~ autotest$ 

所以我认为,如果使用GUI的方式提供Appium server,只需要下载安装文件,安步骤安装就可以,不需要额外的步骤,简单方便,理论支持如下:

http://appium.io/slate/cn/master/?ruby#appium-概念

Appium.app, Appium.exe

我们提供了 GUI 封装的 Appium 服务端下载,它封装了运行 Appium服务端的所有依赖,而不需要担心怎样安装Node.js。其中还包括一个Inspector工具,可以帮助你检查应用的界面层级,这样写测试用例时更方便。



2) Command Line方式安装Appium Server

2-1) 需要安装的文件包括:Nodejs, Appium

brew install node # get node.js

npm install -g appium # get appium

2 - 2) 检查Appium是否安装成功:

android-eb274a48f2bbe8ed:~ autotest$ sudo appium&
[1] 3656
android-eb274a48f2bbe8ed:~ autotest$ info: Welcome to Appium v1.4.1 (REV ce6220829063679bcccf5724515c29569c4a16d9)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug

android-eb274a48f2bbe8ed:~ autotest$ ps aux | grep 3656
root             3656   0.0  0.0  2451408   1928 s003  S     5:33PM   0:00.01 sudo appium
autotest         3663   0.0  0.0  2432780    412 s003  R+    5:36PM   0:00.00 grep 3656
android-eb274a48f2bbe8ed:~ autotest$ 
以上证明我的Node.js 和Appium安装成功

2-3)检查Appium运行所需的环境是否配置成功

android-eb274a48f2bbe8ed:~ autotest$ appium-doctor
Running iOS Checks
✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer
✔ Xcode Command Line Tools are installed.
✔ DevToolsSecurity is enabled.
✔ The Authorization DB is set up properly.
✔ Node binary found at /usr/local/bin/node
✔ iOS Checks were successful.

Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.


3  开发一个python脚本,用于测试ios App

3-1)测试iOS App的python测试脚本,基于Python Client来开发,那么首要问题就是安装Python client(Appium提供了多种语言的client, python, java, ruby...)

推荐使用Pip来安装,安装的命令是:

sudo pip install Appium-Python-Client

Successfully installed Appium-Python-Client-0.14 enum34-1.0.4
android-eb274a48f2bbe8ed:~ autotest$ 

3-2) 开发iOS App测试脚本

你可能感兴趣的:(Appium系列文章1: Appium开发环境搭建)