App自动化01-Appium概述

Appium简介

Appium是一个开源、跨平台的测试工具,可以用来测试原生及混合的移动端应用。Appium支持IOS、Android及Windows 平台。Appium使用WebDriver的json wire协议,来驱动IOS系统的UIAutomation库、Android系统的UIAutomator框架。它允许测试人员在不同的平台(iOS,Android)使用同一套API来写自动化测试脚本,这样大大增加了iOS和Android测试套件间代码的复用性。下面的是为其官网上面的介绍:

Appium is an open-source tool you can use to automate mobile native, mobile web, and mobile hybrid applications on iOS and Android platforms. “Mobile native apps” are those written using the iOS or Android SDKs. “Mobile web apps” are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome on Android). “Mobile hybrid apps” have a native wrapper around a “webview” – a native control that enables interaction with web content. Projects like Phonegap, for example, make it easy to build apps using web technologies that are then bundled into a native wrapper – these are hybrid apps. Importantly, Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android), using the same API. This enables a large or total amount of code reuse between iOS and Android testsuites.

Appium支持Selenium WebDriver支持的所有语言,如Java、Object-C、JavaScript、Php、Python、Ruby、C#、Clojure,或者Perl语言,更可以使用Selenium WebDriver的Api。Appium支持任何一种测试框架。如果只使用Apple的UIAutomation,我们能用javascript来编写测试用例。同样,如果只使用Google的UIAutomater,我们就能用java来编写测试用例。Appium实现了真正的跨平台自动化测试。

Appium与Selenium关系:

  • Appium类库封装了标准Selenium客户端类库,为用户提供所有常见的JSON格式selenium命令以及额外的移动设备控制相关的命令,如多点触控手势等。

  • Appium服务端定义了官方协议的扩展,为Appium 用户提供了方便的接口来执行各种设备动作,例如在测试过程中安装/卸载App。当然,Appium客户端类库只是增加了一些功能,而实际上这些功能就是简单的扩展了Selenium 客户端,所以他们仍然可以用来运行通用的Selenium会话。

Appium相关名词介绍

Appium Server

Appium 的核心是一个web服务器,它提供了一套REST的接口。它收到客户端的连接,监听到命令,接着在移动设备上执行这些命令,然后将执行结果放在 HTTP响应中返还给客户端。事实上,这种客户端/服务端的架构给予了许多的可能性:比如我们可以使用任何实现了该客户端的语言来写我们的测试代码。比如我们可以把服务端放在不同的机器上。比如我们可以只写测试代码,然后使用云服务来执行命令。

Session

自动化始终围绕一个session进行,客户端初始化一个seesion(会话)来与服务端交互,不同的语言有不同的实现方式,但是他们最终都是发送为一个POST请求给服务端,请求中包含一个JSON对象,被称作“desired capabilities”。此时,服务端就会开启一个自动化的 session,然后返回一个 session ID,session ID将会被用户发送后续的命令。

Appium Client

Appium Client 有很多语言库。包括 Java, Ruby, Python, PHP, JavaScript 和 C#,这些库都实现了 Appium 对 WebDriver 协议的扩展。当使用 Appium 的时候,你只需使用这些库代替常规的 WebDriver 库就可以了,我们写脚本的时候用对应的IDE开发工具即可,如java端用eclipse,python端用pycharm。

Appium desktop

我们提供了 GUI 封装的 Appium server端下载,它封装了运行 Appium服务端的所有依赖,而不需要担心怎样安装Node.js。其中还包括一个Inspector工具,可以帮助你检查应用的界面层级让你更方便地编写测试用例。

Bootstrap

实质上是一个jar包,在appium建立和手机端通讯的时候会将此jar包推送到手机中去,负责在手机端和appium server的通讯,将指令下发给UIAutomator。

UIAutomator

Android端真正实现App自动化测试的框架,appium最终会通过Bootstrap.jar将指令发送到UIAutomator,通过UIAutomator来定位元素操作元素。

原文地址:https://www.cnblogs.com/yyoba/p/12394257.html