Build a collection of Python-based environment Appium

Automation has been a hot laps in the chat, we also seek technical direction. In the test, tend to return to the "pain points" test is also testers. For iteration slow, change less function, be able to use automation to replace manual return, reduce the workload.

problem

Before sharing environment set up, one of my first throw doubt it.

When the app is enabled, divided into different scenarios:

1. The first installation is enabled, there is the welcome page;

2. Non-first enabled, go directly to the login page;

3. Configure the recommended display, enabled app, we will first show recommendations, before entering to the login page.

Different scenarios corresponding activity is different, my current approach is to write the input function, if added a judgment to correspond to different activity, do not always feel smart, look Cipian bloggers, whether to recommend doubts about. Thank you.

Having said that, the entry to business. Appium environment to build, you need to install software or several, an installation fails, it could cause the entire environment to build failed. First listed under the software required to use, as follows:

. 1 .jdk-8u221- window (corresponding to the downloaded version)

2 . .Android-sdk_r24 4.1 - Windows (download the latest version)

3.Python

4 .appium

5.Node.js

6 .Appium-python- client

7.pycharm

A, jdk installation

jdk Download: http://www.oracle.com/technetwork/java/javase/downloads/index.html

JDK a key to install, needless to say, the default installation path to the

Environment Configuration: Computer> Properties> Advanced Properties> Environment Variables

Variable name: JAVA_HOME

Variable value: D: \ Java \ jdk1.8.0_73 (here jdk installation path)

Variable name: path

Variable value:% JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin; (java command so that the system can recognize at any path)

Variable name: CLASSPATH

Variable values:;.% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar; (It should be noted that not leak.) Path to the Java runtime environment to load the class

Environment configuration if successful, or java -version javac input validation, the following interface indicates success

 

 

 

 Two, installed SDK tools

The Android SDK provides the necessary development and testing Android API class libraries and development tools

1.sdk Download

sdk Download: https://www.androiddevtools.cn/

We need to download the SDK Tools

 

2. Installation Tools

Installation:

Unzip the downloaded zip package can be installed directly.

Open SDK Manager (first automatic pop-up), in accordance with the default installation also checked. The main installation tools Platform-tools, build-tools, Android API (you can choose the latest version), as well as extensions Google USB Driver, others choose according to the actual situation. As shown below:

 

When the download and install, go outside the network, if you feel the download speed is too slow, you can configure mirroring domestic accelerated.

Change the mirror address Tools -> Options

 

NII mirror server address:
HTTP: // mirrors.neusoft.edu.cn Port: 80 
Beijing University of Chemical Technology mirror server address:
IPv4: HTTP: // ubuntu.buct.edu.cn/ Port: 80 
IPv4: HTTP: // ubuntu.buct.cn/ Port: 80 
IPv6: HTTP: // ubuntu.buct6.edu.cn/ Port: 80 
Shanghai GDG mirror server address:
HTTP: // sdk.gdgshanghai.com port: 8000 
Open Source Institute, Chinese Academy of mirror sites Address:
IPV4 / IPV6: HTTP: // mirrors.opencas.cn Port: 80 
IPV4 / IPV6: HTTP: // mirrors.opencas.org Port: 80 
IPV4 / IPV6: HTTP: // mirrors.opencas.ac.cn ports: 80

Download process, you can go to a cup of tea, take a look at the page, you need a little while yo

3. Set Environment Variables

A cup of tea effort, sdk tools are required for a successful download, the next step is to configure the environment variables.

Environment variable configuration
 . 1 .ANDROID_HOME: D: \ the Android \ Android- SDK their actual installation path
 2 . The Path has an additional variable values:
% ANDROID_HOME% \ Tools; ADNROID_HOME%% \ Platform-Tools; ADNROID_HOME%% \ Build-Tools \ 28.0 . 3 \; own specific version number

4. Verify

Adb command can use the validation, the input window dos adb, appear as theme, the installation is successful

 

 

Three, Python installation

python installation to skip, and just all the way to the next step, do not repeat them.

四, epochs

1. What is Appium

Appium is an open source, cross-platform test frame, the mobile terminal can be used to test the native application and mixing. Appium support IOS, Android and FirefoxOS platform. Appium WebDriver use of json wire protocol, driven Apple UIAutomator framework of UIAutomation library system, Android system. Dan Cuellar's research for IOS automated Appium thanks to support IOS system. Appium also integrated Selendroid, to support older android version.

Appium support Selenium WebDriver all supported languages ​​such as java, Object-C, JavaScript, Php, Python, Ruby, C #, Clojure, or Perl language, but you can use Selenium WebDriver of Api. Appium support any testing framework. If only Apple's UIAutomation, we can only use javascript to write test cases, and only with the Instruction to run test cases. Similarly, if only Google's UIAutomation, we can only use java to write test cases. Appium to achieve a true cross-platform automated testing.

2.Appium works

2.1 Android

In Android end, appium WebDriver based protocol, using bootstrap.jar, by adjusting the final command Use with UiAutomator achieve automated testing App. UiAutomator testing framework that comes with the Android SDK App UI test automation Java libraries.

In addition, as UiAutomator support for H5 limited, appium introduced chromedriver and safaridriver such as to achieve the H5-based automation.

at the end of the workflow appium android follows:

①client end is our webdriver test scripts;

② from the middle is Appium service, Appium in the service reach for a Server (Port: 4723). With selenium Webdriver testing framework similar, Appium ⽀ support standard WebDriver JSONWireProtocol. Provided herein that provides a REST interface, Appium Server receives the rest standard web driver client request, parses the content of the request, transfer the corresponding frame Use response operation;

③appium server will forward the request to the middleware Bootstrap.jar, it is written in java, install .Bootstrap listening 4724 port on your phone and receive appium command, and ultimately to achieve with UiAutomator Use the command transfer;

The results ④Bootstrap will perform returned to appium server;

Finally ⑤appium server returns the results to appium client.

2.2 IOS

In IOS end, appium WebDriver Using the same set of protocols. And Android end frame difference is tested, appium ios apple frame encapsulates Instruments, mainly used in the Instrument UI Automation (Apple's automated testing framework automatically), then the START bootstrap.js feed injection line ⾏ listening device.

at the end of the workflow appium ios follows:

①client end remains our webdriver test scripts;

② from the middle is Appium service, Appium in the service reach for a Server (Port: 4723). With selenium Webdriver testing framework similar, Appium ⽀ support standard WebDriver JSONWireProtocol. Provided herein that provides a REST interface, Appium Server receives the rest standard web driver client request, parses the content of the request, transfer the corresponding frame Use response operation;

③appium server calls instruments.js start a socket server, while the separation of a child process when running a instruments.app, will bootstrap.js (a UIAutomation script) is injected into the device Use to interact with the outside world;

The results ④Bootstrap.js will perform returned to appium server;

Finally ⑤appium server returns the results to appium client.

So we can see the difference android ios that forwards the request to bootstrap.js appium or bootstrap.jar, and then the bootstrap driver UIAutomation UiAutomator to perform specific actions on devices.

More details can be found in this blog post: https://www.cnblogs.com/sophia194910/p/7515165.html

3.Appium installation

Appium Download: https://bitbucket.org/appium/appium.app/downloads/

 

 

The downloaded zip package unzip installation, the installation is very simple, follow the prompts.

Configuration environment variable

Environment variables path: additional environment variable C: \ Program Files (x86) \ Appium \ node_modules \ .bin; specific installation path

verification

Enter the command appium-doctor View, appear the following screenshot, the installation is successful

 

Five, Node.js

Configuration Appium environment, there must be Node.js (Appium is written by the Node.js), Node.js is required to install and configure the environment.

Download: http://nodejs.cn/download/

Download the corresponding version, as shown below

 

After downloading the installation package, double-click the installation by ignoring, it is very simple.

Configuration environment variable

Plus the path environment variable: C: \ Program Files \ nodejs \ node installation path

verification

Command to check the node -v node version, appear the following screenshot, the installation is successful

 

六, epochs-python-client

1. What is Appium-python-Client

Appium practical method are in Client source code, the driver and webelement for instance, have to find the corresponding element method (webelement find is the following child elements), some child-specific functions of the phone, you need to install the rear of the Client be usable.

Appium为了实现自己的find查找方式,首先自定义了一个MobileBy类,给这个类对象塞入了它定义的一些扩展属性,这些属性的值会通过webdriver协议推送到server端去识别和执行,为了让这些属性运用到find方法中,appium很好地继承和扩展了webdriver.Remote,然后通过调用driver实例的find_element和find_elements两个核心方法实现元素查找。所以,既然是扩展,appiumdriver实例可以使用seleniumdriver的所有关于元素查找的实例方法。

2.安装Appium-python-Client

使得appium和python建立连接关系,使用命令:pip install Appium-Python-Client,出现如下截图,则说明安装成功。

 

七、Pycharm

工具安装也忽略了,安装很简单的。

 

经过如上七个步骤的操作,基于Python的Appium环境搭建就成功了。虽说成功了,但也仅仅是个开端而已,想要做好自动化,还是需要静下心来,研习一番。今天的环境搭建就介绍到这了,下次带来genymotion及脚本的分享。有描述错误的地方,欢迎批评指正。

 

本文仅代表作者观点,系作者@温一壶清酒发表。
欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
文章出处:http://www.cnblogs.com/hong-fithing/

Guess you like

Origin www.cnblogs.com/hong-fithing/p/11475812.html