Appium Automation Self-Study Chapter - First introduction to Appium Automation!

Appium Simplification

With the popularity of mobile terminals, there are more and more mobile phone applications and they are becoming more and more important. As testers, we must also keep pace with the times and work hard to learn related testing of mobile apps. This article will introduce the mobile automated testing framework Appium. So what exactly is Appium? Next, let’s learn Python+Selenium for automated testing.

Appium Overview

(1) What is Appium

  • appium is an open source mobile automated testing framework;
  • Appium can test native, hybrid, and mobile web projects;
  • Appium can test ios, android applications (and of course, firefox os);
  • Appium is cross-platform and can be used on osx, windows and linux desktop systems.

(2) Appium’s philosophy

  • There is no need to recompile or modify the test app for automation;
  • Mobile terminal automated testing should not be limited to a certain language and a specific framework; that is to say, anyone can use the language and framework that they are most familiar with and comfortable with to do mobile terminal automated testing;
  • Don’t reinvent the wheel and rewrite a set of earth-shattering APIs for the sake of automated testing on the mobile terminal; that is to say, the APIs in the webdriver protocol are already good enough, and you can just improve them;
  • Automated mobile testing should be open source.

(3) Appium design ideas

  • First of all, in order to achieve the second point described in the philosophy, that is, mobile terminal automated testing should not be limited to a certain language and a specific framework; that is, anyone can use the language they are most familiar with and comfortable with. framework to do automated mobile testing; appium chose the client-server design pattern. As long as the client can send http requests to the server, then the client can use any language to implement it. This is how appium and webdriver support multiple languages;
  • Secondly, in order to be able to achieve the goal of not reinventing the wheel and rewriting a set of earth-shattering APIs for automated testing of mobile terminals; that is to say, the APIs in the webdriver protocol are good enough and can be improved upon; this idea, appium extension I have adopted the webdriver protocol, so I don’t have to re-implement it myself. The advantage of this is that the previous webdriver api can be directly inherited, and the bindings of various languages ​​​​of the previous webdriver can be used immediately, eliminating the workload of developing a client for each language;
  • Finally, appium is of course open source, which also realizes the last point in the philosophical thought.
现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:310357728【暗号:csdn999】

(4) Appium advantages

  • Supported languages: java, python, node.js, c#, php, perl, ruby;
  • Supports android and ios;
  • Cross-application support.

(5) Appium features

  • Cross-architecture, native hybrid webview
  • Cross-device, android ios firefoxos
  • Cross-language, java python ruby ​​nodejs php
  • Cross-app, can interact between multiple apps
  • Does not rely on source code
  • No restrictions on testing frameworks and platforms

(6) Appium architecture

  • Android uses two sets of technologies: instrumentation and uiautomator
  • Appium uses uiautomator on 4.1 and above
  • 4.1 Use selendroid below
  • iOS using uiautomation
  • Support firefox

Appium's architecture on IOS:

Appium's architecture on Andiord:

Appium basic concepts

(1) Client/Server Architecture

The core of appium is actually a server that exposes a series of REST APIs. The function of this server is actually very simple: listen to a port and receive commands sent by the client. Translate these commands, convert these commands into a form that the mobile device can understand, and send them to the mobile device. Then, after the mobile device executes these commands, it returns the execution results to the appium server, and the appium server returns the execution results to the client.

The client here is actually the device that initiates the command. Generally speaking, it is the machine where our code is executed, and the machine where appium test code is executed. In a narrow sense, client can be understood as code. These codes can be java/ruby/python/js, as long as it implements the webdriver standard protocol. This design idea brings some benefits:

  • Can bring multi-language support;
  • The server can be placed on any machine, even a cloud server; (yes, appium and webdriver are naturally suitable for cloud testing).

(2) Session

A session is a session. In webdriver/appium, all your work can only be done after session start. Generally speaking, the session can be opened by POST /session URL and then passing in Desired Capabilities.

After opening the session, a globally unique session id will be returned. Almost all future requests must bring this session id, because this session id represents the browser you opened or the emulator of the mobile device.

Thinking about it further, since the session id is globally unique, it becomes possible to start multiple sessions on the same machine. This is the specific theoretical basis on which selenium gird relies.

(3) Desired Capabilities

Desired Capabilities carry some configuration information. Essentially, this stuff is an object in the form of key-value. You can understand it as map in java, dictionary in python, hash in ruby ​​and json object in js. In fact, Desired Capabilities are json objects when transmitted.

The most important role of Desired Capabilities is to tell the server the context of this test. Are we going to do browser testing or mobile testing this time? If it is a mobile test, should it be tested on android or ios? If it is tested on android, which app should we test? These Desired Capabilities questions of the server must be answered. Otherwise, if the server does not buy it, it will naturally not be able to complete the startup of the mobile app or browser.

(4) App Server

Appium Server is what we open every time we use the appium command on the command line.

(5) App Clients

Since the native webdriver api is designed for the web, it will be a bit nondescript when used on the mobile side. Appium officially provides a set of appium clients, covering multiple languages ​​ruby/java/python. In my opinion, ruby ​​client is the best implementation. During testing, these client libraries are generally used to replace the native webdriver library. This is not actually a replacement. It is a client that has made some mobile extensions to the native webdriver and added some convenient methods, such as swipe. The appium client allows us to write more readable test cases more conveniently.

(6) Appium.app, Appium.exe

The GUI version of appium server, the former is used on osx and the latter is used on windows. Visualization, no need to install node, and you can see the UI structure of the app are the selling points of this stuff.

Appium and Selenium

  • Selenium2 is also called Selenium Webdriver
  • Appium Clients extends Selenium’s WebDriver API
  • Appium Server implements most of the methods that exist in Selenium and is a third-party webdriver of Selenium.

Appium environment setup

One of the biggest difficulties in learning appium is the installation of the environment. The installation process is relatively cumbersome, and there are many tools and steps to install. The following is the installation process for Android mobile phones based on Windows system. Just like when we use Selenium for web automation testing, we need a browser to execute the test script. So for mobile automation testing, we also need an Android phone (the phone needs to be connected to the computer) or an Android emulator.

In the next section, we will build the environment for Appium and install and use JDK.

Finally, I would like to thank everyone who read my article carefully. Looking at the increase in fans and attention, there is always some courtesy. Although it is not a very valuable thing, if you can use it, you can take it directly!

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are from the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.
 

Insert image description here

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/134934664