Appium翻译篇【 appium/docs/en/about-appium/intro.md 】

文章目录

  • Introduction to Appium
  • Appium Philosophy
  • Appium Design
  • Appium Concepts
    • Client/Server Architecture
    • Session
    • Desired Capabilities
    • Appium Server
    • Appium Clients
    • ==Appium Desktop==
  • Getting Started

Introduction to Appium

Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS mobile, Android mobile, and Windows desktop platforms. Native apps are those written using the iOS, Android, or Windows SDKs. Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android). Hybrid apps have a wrapper around a “webview” – a native control that enables interaction with web content. Projects like Apache Cordova or Phonegap make it easy to build apps using web technologies that are then bundled into a native wrapper, creating a hybrid app.

Importantly, Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android, Windows), using the same API. This enables code reuse between iOS, Android, and Windows testsuites.

For specific information about what it means for Appium to “support” its platforms, and automation modalities, please see the platform support doc.

Appium是一个开源工具,用于iOS移动平台、Android移动平台和Windows桌面平台上的原生、移动web和混合应用程序的自动化。原生应用是指那些使用iOS、Android或Windows sdk编写的应用。移动web应用程序是通过移动浏览器访问的web应用程序(Appium支持iOS上的Safari和Chrome或Android上内置的浏览器应用程序)。混合应用程序有一个webview包装器——一个可以与web内容交互的原生控件。类似于Apache Cordova或Phonegap项目,可以很容易地使用web技术构建应用程序,然后将这些应用程序打包到一个原生包装器中,创建一个混合应用程序。
重要的是,Appium是跨平台的:它允许你用相同的API编写针对多个平台(iOS, Android, Windows)的测试。这使得iOS、Android和Windows测试套件之间的代码重用成为可能。
有关Appium支持其平台和自动化模式的具体信息,请参阅platform support doc。

Appium Philosophy

Appium was designed to meet mobile automation needs according to a philosophy outlined by the following four tenets:

  1. You shouldn’t have to recompile your app or modify it in any way in order to automate it.
  2. You shouldn’t be locked into a specific language or framework to write and run your tests.
  3. A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
  4. A mobile automation framework should be open source, in spirit and practice as well as in name!

Appium的设计是为了满足移动自动化的需要,如下四个原则:

  1. 不应该为了自动化而重新编译你的应用或者修改它。
  2. 不应该被限制在特定的语言或框架中来编写和运行测试。
  3. 当涉及到自动化api时,一个移动自动化框架不应该重新造轮子。
  4. 当涉及到自动化api时,一个移动自动化框架不应该重新发明轮子。

Appium Design

So how does the structure of the Appium project live out this philosophy? We meet requirement #1 by using vendor-provided automation frameworks under the hood. That way, we don’t need to compile in any Appium-specific or third-party code or frameworks to your app. This means you’re testing the same app you’re shipping. The vendor-provided frameworks we use are:

  • iOS 9.3 and above: Apple’s XCUITest
  • iOS 9.3 and lower: Apple’s UIAutomation
  • Android 4.3+: Google’s UiAutomator/UiAutomator2
  • Windows: Microsoft’s WinAppDriver

那么Appium项目的结构是如何实现这一理念的呢?
为了实现需求#1,使用供应商提供的自动化框架。这样,就不需要把 Appium 特定的或者第三方的代码编译进应用,这也意味着正在测试的应用和最终发布的应用是一样的。我们使用的供应商提供的框架是:

  • iOS 9.3 及以上: XCUITest
  • iOS 9.3 及以下: UIAutomation
  • Android 4.3+: UiAutomator/UiAutomator2
  • Windows: WinAppDriver

We meet requirement #2 by wrapping the vendor-provided frameworks in one API, the WebDriver API. WebDriver (aka “Selenium WebDriver”) specifies a client-server protocol (known as the JSON Wire Protocol). Given this client-server architecture, a client written in any language can be used to send the appropriate HTTP requests to the server. There are already clients written in every popular programming language. This also means that you’re free to use whatever test runner and test framework you want; the client libraries are simply HTTP clients and can be mixed into your code any way you please. In other words, Appium & WebDriver clients are not technically “test frameworks” – they are “automation libraries”. You can manage your test environment any way you like!

为了实现需求#2,将供应商提供的框架包装在一个API (WebDriver API)中。WebDriver(又名“Selenium WebDriver”)指定了一个客户端-服务器协议(称为JSON有线协议)。对于这种客户机-服务器体系结构,可以使用任何语言编写的客户机向服务器发送适当的HTTP请求。现在已经有了用每种流行编程语言编写的客户机。这也意味着你可以自由地使用任何你想要的测试运行器和测试框架;客户端库只是简单的HTTP客户端,可以按照您的喜好将其混合到您的代码中。

We meet requirement #3 in the same way: WebDriver has become the de facto standard for automating web browsers, and is a W3C Working Draft. Why do something totally different for mobile? Instead we have extended the protocol with extra API methods useful for mobile automation.

以同样的方式实现需求#3:WebDriver 已经成为 Web 浏览器自动化事实上的标准,并且是一个 W3C 工作草案。何必在移动端做完全不同的尝试?相反,我们通过附加额外的 API 方法 扩展协议,这些方法对移动自动化非常有用。

It should be obvious that requirement #4 is a given – you’re reading this because Appium is open source.

显然,需求#4是已知的——阅读本文就是因为Appium是开源的。

Appium Concepts

Client/Server Architecture

Appium is at its heart a webserver that exposes a REST API. It receives connections from a client, listens for commands, executes those commands on a mobile device, and responds with an HTTP response representing the result of the command execution. The fact that we have a client/server architecture opens up a lot of possibilities: we can write our test code in any language that has a http client API, but it is easier to use one of the Appium client libraries. We can put the server on a different machine than our tests are running on. We can write test code and rely on a cloud service like Sauce Labs to receive and interpret the commands.

Appium本质上是一个暴露REST API的网络服务器,。它接收来自客户机的连接,侦听命令,在移动设备上执行这些命令,并使用表示命令执行结果的HTTP响应进行响应。客户机/服务器架构提供了很多可能性:我们可以用任何具有http客户端API的语言编写测试代码,但是使用Appium客户端库更容易。我们可以将服务器放在其他机器上,而不是运行测试的机器。我们可以编写测试代码并依赖于像Sauce Labs这样的云服务接受和解释命令。

Session

Automation is always performed in the context of a session. Clients initiate a session with a server in ways specific to each library, but they all end up sending a POST /session request to the server, with a JSON object called the ‘desired capabilities’ object. At this point the server will start up the automation session and respond with a session ID which is used for sending further commands.

自动化总是在会话的上下文中执行,客户端库以特定于每个库的方式与服务器发起会话,但它们最终都向服务器发送了一个POST /session请求,以及一个名为“所需功能”对象的JSON对象。此时,服务器将启动自动化会话并使用一个用于发送进一步命令的会话ID进行响应。

Desired Capabilities

Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server to tell the server what kind of automation session we’re interested in starting up. There are also various capabilities which can modify the behavior of the server during automation. For example, we might set the platformName capability to iOS to tell Appium that we want an iOS session, rather than an Android or Windows one. Or we might set the safariAllowPopups capability to true in order to ensure that, during a Safari automation session, we’re allowed to use JavaScript to open up new windows. See the capabilities doc for the complete list of capabilities available for Appium.

所需功能是一组发送到Appium服务器的键和值(map或hash),以告诉服务器我们想要启动哪种自动化会话。还有各种各样的功能可以在自动化过程中修改服务器的行为。例如,我们可以设置iOS的platformName功能来告诉Appium我们想要一个iOS会话,而不是一个Android或Windows会话。或者我们可以将safariAllowPopups功能设置为true,以确保在Safari自动化会话期间,我们可以使用JavaScript打开新的窗口。有关Appium可用功能的完整列表,请参阅 capabilities doc。

Appium Server

Appium is a server written in Node.js. It can be built and installed from source or installed directly from NPM:

Appium 是一个用 Node.js 写的服务器。可以从源码构建安装或者从 NPM 直接安装:

$ npm install -g appium
$ appium

The beta of Appium is available via NPM with npm install -g appium@beta. It is the development version so it might have breaking changes. Please uninstall appium@beta (npm uninstall -g appium@beta) before installing new versions in order to have a clean set of dependencies.

Appium 的 beta 版本可以通过 NPM 使用 npm install -g appium@beta 指令进行安装。它是开发版本,所以可能存在破坏性的变更。在安装新版本前,请卸载 appium@beta (npm uninstall -g appium@beta)以获得一组干净的依赖。

Appium Clients

There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium’s extensions to the WebDriver protocol. When using Appium, you want to use these client libraries instead of your regular WebDriver client. You can view the full list of libraries here.

有一些客户端库(Java、Ruby、Python、PHP、JavaScript和c#)支持Appium对WebDriver协议的扩展。在使用Appium时,您希望使用这些客户端库而不是常规的WebDriver客户端。您可以在here查看库的完整列表。

Appium Desktop

There is a GUI wrapper around the Appium server that can be downloaded for any platform. It comes bundled with everything required to run the Appium server, so you don’t need to worry about Node. It also comes with an Inspector, which enables you to check out the hierarchy of your app. This can come in handy when writing tests.

这有一个 Appium 服务器的图形界面可以下载,它适用于任何平台。它打包了 Appium 服务器运行需要的所有东西,所以你不需要为 Node 而烦恼。它们还提供一个 Inspector 使你可以查看应用程序的层级结构。这在写测试时可以派上用场。

Getting Started

Congratulations! You are now armed with enough knowledge to begin using Appium. Why not head to the getting started doc for more detailed requirements and instructions?

恭喜你!现在已经掌握了足够的知识,可以开始使用Appium了。为什么不去getting started doc获取更详细的要求和说明呢?

你可能感兴趣的:(Appium翻译篇,其他,程序人生,经验分享)