How Appium Automation Works (1)

Source: Internet
Author: User

Develop mobile automation test scripts with Appium for so long, there is no certification to understand what the rationale is, in the end how to achieve it?

1, first look at a appium loading process diagram (from: Understanding how Appium Automation Works--69220719/)

Loading process of Appium

1) Call Android ADB to complete basic system operation

2) Deploy Bootstrap.jar to Android

3) Bootstrap.jar Forward Android port to PC machine

4) Listening port on PC receiving request, using Webdriver protocol

5) Analyze command and send to Bootstrap.jar via forward port

6) Bootstrap.jar receive the request and send the command to Uiautomator

7) Uiautomator Execution command

2, preliminary understanding of appium work process

1.appium is the C/s mode
2.appium is based on the Webdriver protocol added to the mobile Device Automation API extension, so with the same features as Webdriver, such as multi-language support
3.webdriver is based on the HTTP protocol, the first connection will establish a session, and send a JSON via post to inform the server related test information
4. For Android, 4.2 is based on the Uiautomator framework to achieve the discovery injection event, 4.2 is the instrumentation framework, and encapsulated into a service called selendroid
5. The client only needs to send HTTP requests for communication, which means that the client is multi-language supported
The 6.appium server is written by node. js, so you install it regardless of which platform installs node first, then NPM install-g appium installation (FQ wall)

3, Bootstrap Introduction

1) Bootstrap effect:

Bootstrap is a uiautomator test script that Appium runs on the Android target test machine, The only thing that the script does is to open a socket server on the target machine to send a command that appium from the PC to Uiautomator in a session to perform the processing.

It listens to port 4724 for commands and passes it to uiautomator for processing.

2) The role played by Bootstrap in Appium:

First, Bootstrap is the Uiautomator test script, its entry class bootstrap inherit from Uiautomatortestcase, so uiautomator can run it properly, it can also use the Uiautomator method , this is the key to the Appium command that can be converted into a uiautomator command;

Second, Bootstrap is a socket server, specifically listening to 4724 ports over the Appium connection and command data, and the Appium command to convert to Uiautomator command to allow the uiautomator to handle;

Finally, bootstrap deals with commands that come from the PC, not a file.

4, the use of technology

Android uses instrumentation and uiautomator two sets of technologies

iOS using UIAutomation

Firefox is also supported and can be extended to other platforms

Default on port 4723 accepts Webdriver request, 4723 is Appium service, specialized and script deal with;

Default on 4724 to communicate with Android devices

Wu, capabilities

Capabilities is a set of key-value pairs that the client sends to the Appium server to tell the server what kind of session we want to start. There are also key-value pairs that are used to modify the behavior of the server side during automation.

Second, appium working principle 2.1 Android

On the Android side, Appium is based on the Webdriver protocol, using Bootstrap.jar, and finally using uiautomator commands to automate the app's testing.

The Uiautomator test framework is an app UI Automation test Java library that comes with the Android SDK.

In addition, thanks to Uiautomator's limited support for H5, Appium introduced Chromedriver and safaridriver to implement H5-based automation.

Appium on Android side workflow
    1. The client side, which is our test script, is our webdriver.

    2. In the middle is the Appium service, Appium a server (4723 port) on the service side, similar to the Seleniumwebdriver test framework, Appium the standard webdriverjsonwireprotocol. Provided here it provides a set of rest interfaces, Appium server receives the Web Driverclient standard rest request, parses the request content, and responds to the action with the corresponding framework.

    3. Appium server forwards the request to the middleware Bootstrap.jar, which is written in Java and installed on the phone. Bootstrap listens to 4724 ports and receives Appium commands, which are finally implemented with Uiautomator commands.

    4. Finally, Bootstrap returns the results of the execution to Appium server.

    5. Appium server then returns the result to the Appium client.

2.2 iOS

On the iOS side, Appium also makes? Webdriver a set of protocols.

Unlike the Android-side test framework, Appium iOS encapsulates Apple's instruments framework, mostly using uiautomation in instrument (Apple's Automated test framework) and then making a note in the device. Into the bootstrap.js to monitor the line.

Appium Workflow on iOS side
    1. The client side is still test script, which is our webdriver testing scripts.

    2. In the middle is the Appium service, Appium a server (4723 port) on the service side, similar to the Seleniumwebdriver test framework, Appium the standard webdriverjsonwireprotocol. Provided here it provides a set of rest interfaces, Appium server receives the Web Driverclient standard rest request, parses the request content, and responds to the action with the corresponding framework.

    3. Appium server call Instruments.js start? A Socketserver, and a sub-process? Instruments.app, will Bootstrap.js (a uiautomation script) note? into device? To interact with the outside world

    4. Finally bootstrap.js returns the result of the execution to the Appium server

    5. Appium server then returns the result to the Appium client.

So we can see that the difference between Android and iOS is that Appium forwards the request to Bootstrap.js or Bootstrap.jar. Then the bootstrap drive UIAutomation and uiautomator to the devices to complete the specific action.

How Appium Automation Works (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.