Abstract: Appium is an open source tool for mobile automation testing, which can write test cases for different platforms using a set of apis. This article summarizes the functions of Appium automated testing framework. This text is selected from software Automated Test Development

Appium framework features

(1) Support iOS, Android, parallel App automation on multiple machines, test model adaptation. (2) Code implementation keyword driver:

Test suite: Associate Excel test cases with script configuration. Test data: Excel stores input data, control elements, and test results. Test scripts: written in Java and TestNG, hierarchical structures include case, log, config, report, and data. (3) Automatic test case execution:

The main functions that need to be repeated are extracted from the functional test cases for use case coverage. Automatic screen capture when use cases failed is supported. The failed case is automatically repeated for several times. (4) Jenkins, continuous integration environment, automatically builds and executes test tasks on a regular basis.

Test results report display, automatic email display. The basic process for Appium to automate testing an App is as follows:

The basic process of testing your App

Based on Appium automated testing framework, we need to carry out a series of detailed automatic test execution processes, such as connecting computer, connecting mobile phone, unlocking, installing App, uninstalling App, starting App, element positioning, element operation, screen operation, page waiting, exception handling screenshots, data verification, log, report and so on.

Appium automates the capture of frame element controls and operates accordingly according to captured element controls.

Appium element controls have a variety of positioning methods, the most common being the element ID (by.id) and the element value (by.name). You can also locate by element type TagName, element location XPath, mobile device coordinates, and so on. Android element controls can be recorded and captured through the UIAutomatorViewer. bat file in SDK, as shown in the following figure.

In the figure above, resource-id com.test.seller:id/phone_edit1 corresponds to the location method by. id in Excel and code. Control element data text 13798359580 corresponding to Excel and code operation method sendkeys(), control element assignment data is 13798359580. First find the text box, then enter data into the text box. The ID attribute value com.test.Seller: ID /phone_edit1 is used to locate the control element of the user name text box and enter the user name data 13798359580 into the user name text using the sendkeys() method. The positioning, control elements, and manipulation of other automated test steps are similar. In fact, automated testing is the process of simulating manual testing through program code. The user name textbox was entered using sendkeys(), but what about other elements? There are roughly click (Click), input (sendkeys), element slide, page slide, long press, drop down, pop up, screen zoom in and out, etc. The most commonly used methods are click and input. Data verification. The element itself is data validation, and the use case fails when the program cannot find the element. In addition, you can add one or more assertions to validate data when testing a case, and you can set the step wait delay. Test results. Test cases record test results after running, such as pass, failed, or SKIP. (This part will be explained in detail in Chapter 4 of Software Automated Test Development)

Appium is an open-source mobile test automation tool that supports iOS and Android platforms, Python, Java, and other languages. The same Set of Java or Python scripts can run on both iOS and Android. Appium is cross-platform, meaning that test cases can be written with a single SET of apis for different platforms. Appium is a C/S architecture with a Web server at its core that provides a set of REST interfaces. When a client connection is received, commands are listened for, executed on the mobile device, and the results are returned to the client in an HTTP response.

Session automation always revolves around a Session (Session). The client initiates a Session to interact with the server. Different languages do this differently, but they all end up sending a POST request to the server that contains a JSON object, which can be called “Desired Capabilities.” At this point, the server will open an automated Session and return a Session ID, which will be used to send subsequent commands.

Desired Capabilities A Desired Capabilities is a collection of key-value pairs (such as a map or hash). The client sends these key-value pairs to the server, telling the server how we want to test them. For example, we could set the platformName Capability to iOS and tell the Appium server that we want an iOS session, not an Android session.

Appium Server is written in Node.js, which can be compiled from source code or installed directly from NPM. Appium server has many language libraries, such as Java, Ruby, Python, PHP, JavaScript and C#, which implement Appium extensions to the WebDriver protocol. When using Appium, you simply use these libraries instead of the regular WebDriver library.

When writing a case in your preferred language, add the WebDrvier extension to your environment. When writing a case in your preferred language, add the WebDrvier extension to your environment. In this case you can think of it as a client. The installation package of the Appium client is as follows: Running appium.dmg directly on Mac machines; Run appium.exe on a Windows machine.

How Appium works on Android/iOS

The API interface calls the interface of Selenium, and Appium Server receives the WebDriver standard request, parses the request content, and invokes the corresponding framework response operation. The code combines the key-value pairs in DesiredCapability into a JSON, which is then sent to the Appium server over HTTP to create a session. All of your code’s interaction with Appium is around this session. After the session is successfully created, Appium creates TCP connections between the USB interface and the mobile phone. First, install some server apps, such as Android API 4.2+ IS UIAutomator, Android 2.3+ is Instrumentation; If it’s iOS, it’s UiAutomation. Appium sends instructions to UIAutomator, and then UIAutomator controls the operations of the phone.

The schematic diagram of Appium is shown below.

At the heart of Appium is a Restful Web server that receives connections and commands from clients, executes them on mobile devices, and collects the results of command execution through HTTP responses. This architecture gives us a nice open feature: as long as a language has an HTTP client API, we can write our own test code in that language. [From “Software Automation test Development”, click this link can be viewed in the blog view website.] (www.broadview.com.cn/book/98?spm…