在技术架构层面,Appium 提供了一种独立于应用平台的设计模式,使其能够在不同的操作系统环境下运行。最核心的实现之一是通过 WebDriver Protocols 协议,这使得开发者能够使用相同的 API 从不同平台调用自动化功能,大大增强了跨平台的兼容性。在底层实现上,Appium 将所有平台接口映射到一组通用的抽象之上,再映射到底层的实际调用上。这种设计不仅使开发人员在开发自动化测试脚本时能够保持一致,而且只需学习和维护一套 API 即可。
graph TD
A[用户编写测试脚本] --> B[通过 WebDriver 协议发送请求]
B --> C[Appium Server]
C --> D{"平台识别"}
D -->|"iOS"| E[iOS 自动化组件]
D -->|"Android"| F[Android 自动化组件]
D -->|"其他平台"| G[其他自动化组件]
C --> H{"设备选择"}
H -->|"实际设备"| I[运行在实际设备上]
H -->|"模拟器/模拟器"| J[运行在模拟器上]
这个架构图是 Appium 在维护跨平台一致性和处理不同设备请求时的基本流程示例。
功能亮点与差异
Appium 具备支持广泛类型的应用(iOS、Android 和 Web 应用)的能力,这一点相比其他自动化测试框架来说,显著提升了其交叉平台操作的优势。同时,因为开放性和社区支持的广度,Appium 在解决问题时通常比其他解决方案能够更快地发现问题并整合解决方案。这些特征使得 Appium 成为了市场上领先的选择。
Appium is an open-source automation framework that provides
WebDriver-based automation possibilities for a wide range of
different mobile, desktop and IoT platforms. Appium is modular and extensible, and supports multiple
programming languages, which means there is an entire ecosystem of related software:
Drivers add support for automating specific platforms
Clients allow writing Appium tests in your programming language of choice
Plugins allow to further extend Appium functionality
Upgrading From Older Versions
The Appium team only provides support for the most recent version of Appium. If you wish to upgrade from
an older major Appium version, please refer to the migration guides:
Appium can be installed using npm (other package managers are not currently supported). Please
check the installation docs for the
system requirements and further information.
If upgrading from Appium 1, make sure Appium 1 is fully uninstalled (npm uninstall -g appium).
Unexpected errors might appear if this has not been done.
npm i -g appium
Note that this will only install the core Appium server, which cannot automate anything on its own.
Please install drivers for your target platforms in order to automate them.
Drivers
Appium supports app automation across a variety of platforms, like iOS, Android, macOS, Windows,
and more. Each platform is supported by one or more “drivers”, which know how to automate that
particular platform. You can find a full list of officially-supported and third-party drivers in
Appium Ecosystem’s Drivers page.
# Install an official driver from npm (see documentation for a list of such drivers)
appium driver install <driver-name>
# Install any driver from npm
appium driver install --source=npm <driver-name>
# See documentation for installation from other sources
# List already installed drivers
appium driver list --installed
# Update a driver (it must be already installed)
# This will NOT update the major version, in order to prevent breaking changes
appium driver update <driver-name>
# Update a driver to the most recent version (may include breaking changes)
appium driver update <driver-name> --unsafe
# Uninstall a driver (it won't last forever, will it?)
appium driver uninstall <driver-name>
Clients
Client libraries enable writing Appium tests in different programming languages. There are
officially-supported clients for Java, Python, Ruby, and .NET C#, as well as third-party clients
for other languages. You can find a full list of clients in
Appium Ecosystem’s Clients page.
Plugins
Plugins allow you to extend server functionality without changing the server code. The main
difference between drivers and plugins is that the latter must be explicitly enabled on
Appium server startup (all installed drivers are enabled by default):
# Install an official plugin from npm (see documentation for a list of such plugins)
appium plugin install <plugin-name>
# Install any plugin from npm
appium plugin install --source=npm <plugin-name>
# See documentation for installation from other sources
# List already installed plugins
appium plugin list --installed
# Update a plugin (it must be already installed)
# This will NOT update the major version, in order to prevent breaking changes
appium plugin update <plugin-name>
# Update a plugin to the most recent version (may include breaking changes)
appium plugin update <plugin-name> --unsafe
# Uninstall a plugin
appium plugin uninstall <plugin-name>
Server Command Line Interface
In order to start sending commands to the Appium server, it must be running on the URL and port
where your client library expects it to listen. Appium’s command-line interface
is used to launch and configure the server:
# Start the server on the default host (0.0.0.0) and port (4723)
appium server
# You can also omit the 'server' subcommand
appium
# Start the server on the given host, port and use a custom base path prefix (the default prefix is '/')
appium --address 127.0.0.1 --port 9000 --base-path /wd/hub
Appium supports execution of parallel server processes, as well as parallel driver sessions within a
single server process. Refer the corresponding driver documentations regarding which mode is optimal
for the particular driver or whether it supports parallel sessions.
Why Appium?
You usually don’t have to recompile your app or modify it in any way, due to the use of standard
automation APIs on all platforms.
You can write tests with your favorite dev tools using any WebDriver-compatible language such as
Java, Python, Ruby and C#. There are also third party client implementations for other languages.
You can use any testing framework.
Some drivers like xcuitest and uiautomator2 have built-in mobile web and hybrid app support.
Within the same script, you can switch seamlessly between native app automation and webview
automation, all using the WebDriver model that’s already the standard for web automation.
You can run your automated tests locally and in a cloud. There are multiple cloud providers that
support various Appium drivers (mostly targeting iOS and Android mobile automation).
Appium Inspector can be used to visually inspect
the page source of applications across different platforms, facilitating easier test development.
Investing in the WebDriver protocol means you
are betting on a single, free, and open protocol for testing that has become a web standard. Don’t
lock yourself into a proprietary stack.
For example, if you use Apple’s XCUITest library without Appium, you can only write tests using
Obj-C/Swift, and you can only run tests through Xcode. Similarly, with Google’s UiAutomator or
Espresso, you can only write tests in Java/Kotlin. Appium opens up the possibility of true
cross-platform native app automation, for mobile and beyond!
If you are looking for a more comprehensive description of what this is all about, please read our
documentation on How Does Appium Work?.
评论