Android testing of Macaca automated testing

Macaca PC -side  web automation testing is very similar to Selenium , and mobile-side automation testing is very similar to Appium . If you have built an Appium environment, the Macaca mobile environment will be very simple to build.

 

This article inherits the previous one, and I will no longer teach you about the installation of Node.js.

http://www.cnblogs.com/fnng/p/5873878.html

 

Take a look at what Macaca 's Android environment requires before installing it .

From the cmd command prompt, enter the " macaca doctor " command.

 The above picture is my configured environment. We probably need these things, Java development environment, Android SDK environment, ANT build tool. Well, next install them one by one.

 

 

Install the Java  environment                       

 

As we all know, Android is developed by the Java language, so if we want to develop Android applications , we first need the Java environment. Therefore, we first need to install the Java environment.

java download address: http://www.java.com/zh_CN/download/manual.jsp

Open the download link and select the corresponding version to download. Let's take Windows installation JDK as an example,

Double-click the downloaded JDK and set the installation path. Here I choose to install by default at :

D:\Program Files (x86)\Java\jdk1.8.0_25\ directory.

Set the environment variables below:

"My Computer" right-click menu--->Properties--->Advanced--->Environment Variables--->System Variables--> New ..

Variable name: JAVA_HOME

Variable value: D:\Program Files (x86)\Java\jdk1.8.0_25

Variable name: CALSS_PATH

Variable value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

 

 

 

 

 

Find the path variable name -> "Edit" to add:

variable name: PATH

Variable amount:% JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin;

 

 

 

 

 

Install Ant Build Tools                       

 

Apache Ant is a tool that automates the steps of software compilation, testing, deployment, etc. It is mostly used for software development in the Java environment.

Download address: http://ant.apache.org/manualdownload.cgi

After downloading the zip package, unzip it. My unzip location is: D:\java\apache-ant

Then, add the directory to the environment variable path .

variable name: PATH

Variable value: D:\java\apache-ant;

 

 

 

 

 

Install the Android SDK                   

 

The Android SDK provides you with API libraries and development tools to build, test and debug applications for Android . Simply put, the Android SDK  can be seen as a piece of software for developing and running Android applications.

Official address: http://developer.android.com

Of course, I can't guarantee you can access this address, you know why!

However, you can also download Studio and SDK from this address .

http://www.android-studio.org/index.php/download

如果只是想运行Android模拟器,单独下载SDK也可以。

Android SDKWindows)百度网盘下载地址:http://pan.baidu.com/s/1kVOvxEB

Android SDK下载解压目录如下:

下面设置Android环境变量,方法与java环境变量类似。我本机的目录结果为:

D:\android\android-sdk-windows\

下面设置环境变量:

“我的电脑”右键菜单--->属性--->高级--->环境变量--->系统变量-->新建..

变量名:ANDROID_HOME

变量值:D:\android\android-sdk-windows

 

 

 

找到path变量名—>“编辑”添加:

变量名:PATH

变量值:;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;

 

 

 

双击启动SDK Manager.exe 程序。

当然,我不能保证你SDK可以更新。所以,这里推荐腾讯的源:

https://dsx.bugly.qq.com/repository/1

需要通过你的QQ号登录,然后,点击“配置信息”标签页,将会得到一个代理地址和端口号。

Android SDK Manager 的菜单栏上点击“Tools---->Options...”设置相关代码,如下图:

然后,就可以更新了,这里需要勾选“Android SDK Tool”、“Android SDK Platform-tool”和“Android SDK Build-tool”几个选项。点击“Install..”按钮进行安装。

最后,通过cmd命令提示符,输入“macaca doctor”命令,查看所有选项是否已经安装。

 

 

安装Android 模拟器                                        

 

现在可以下载一个Android 版本的模拟器了。国内主流的Android手机主要集中在Androd5.1Android6.0。我这里以Android 5.1.1版本为例。

如上图,勾选所需要安装的工具,点击右下角Install x packages...

当所有勾选项都安装后,进入到D:\android\android-sdk-windows\目录,双击“AVD Manager.exe”,打开窗口如下。

点击Create....

如果显示屏分辨率比较底的话,尽量选择低分辨率的“Device”。

点击OK”,在AVD  Manager 窗口,点击“Start...”按钮启动android 模拟器。

 

 

运行Macaca sample                                        

 

启动android 模拟器,查看虚拟机信息。

与前一篇相同,下载官方例子:

https://github.com/macacajs/macaca-test-sample

 

# git download

> git clone https://github.com/macacajs/macaca-test-sample.git

>cd  macaca-test-sample

 

#init sample

macaca-test-sample>cnpm i

 

#run android sample

macaca-test-sample>macaca run -d ./macaca-test/macaca-mobile-sample.test.js

 

运行效果如下图:

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042866&siteId=291194637