Appium is an open-source automation framework that makes mobile app testing a lot more efficient by offering scalability and flexibility. Mobile testing using Appium has gained traction in the mobile application industry with its extensive features in a short period.
Overview
Appium follows a client-server architecture using the WebDriver protocol, similar to Selenium.
- Appium Client: Test scripts send commands via libraries in languages like Java, Python, and JS.
- Appium Server: Receives client commands and routes them to the platform-specific automation engine.
Appium uses these platform-specific engines to control mobile apps:
- iOS: WebDriverAgent (WDA) + XCUITest
- Android: UiAutomator2 (or UiAutomator/Espresso for legacy support)
- Windows: WinAppDriver + Windows UI Automation API
Appium Workflow: Client → Server → Automation Framework → Device → Response back to Client.
This Appium tutorial aims to offer a detailed overview of the framework, covering all necessary information and benefits that could help you leverage this fantastic automation testing framework for mobile applications.
What is Appium?
Appium is an open-source framework that allows QAs to conduct automated app testing on different platforms like Android, iOS, and Windows.
It automates testing for:
- Native Mobile Applications that are written using iOS, Android, or Windows SDKs
- Mobile Web Applications that can be accessed using mobile browsers such as Safari, Chrome, or in-built native browser applications for android devices
- Hybrid Mobile Applications that have a native wrapper around the web view
Appium is a cross-platform testing framework that is flexible, enabling testers to write test scripts against multiple platforms such as iOS, Windows, and Android using the same API. That means QAs can use the same code for iOS as for Android, time and effort.
Similar to Selenium, Appium allows QAs to write test scripts in different programming languages, which include Java, JavaScript, PHP, Ruby, Python, and C#.
Architecture of the Appium Framework
Appium is an HTTP server that is written on the Node.js platform whose set up comprises a REST (Representational State Transfer) API and implements Selenium WebDriver. It works on a client/server architecture. Appium allows the uses of the available WebDriver client for firing the tests.
The REST API performs the following actions:
- Receives the connection from the client-side
- Listens to the command
- Executes the command on a mobile device
- Returns the command execution status as an HTTP response to the client
Appium allows automation in the context of a session. The client initiates this session as per the client library (Java, JavaScript, PHP, Ruby, Python, and C#), which ends up sending a POST /session request to the server with the help of a JSON object that is termed as Desired capabilities object.
It is then that the server starts the automation session and responds with a session ID that is further used for sending other commands relevant to the given session.
How does Appium work?
Appium operates on a client-server architecture, leveraging the WebDriver protocol (also known as the W3C WebDriver specification), which is the same protocol used by Selenium for web browser automation.
This design enables Appium to interact with mobile applications consistently and standardize across different platforms.
Here’s a breakdown of the key components and the workflow:
1. Appium Client: Test scripts are written using an Appium client library. These libraries are available in various programming languages such as Java, Python, Ruby, JavaScript, C#, and PHP. The client libraries translate test commands (e.g., find element, click, send keys) into JSON Wire Protocol or W3C WebDriver protocol messages.
2. Appium Server: The Appium server acts as an intermediary, receiving commands from the client and forwarding them to the appropriate mobile automation framework based on the platform under test. The Appium server is typically written in Node.js. Upon receiving a command, the server establishes a session with the mobile device or simulator/emulator.
3. Automation Frameworks: Appium utilizes platform-specific automation frameworks to interact with the mobile operating system and applications:
- iOS: Appium employs Apple’s WebDriverAgent (WDA). WDA is a WebDriver server implemented by Apple that runs on an iOS device. Appium proxies commands to WDA, which then interacts with the iOS UI using Apple’s XCUITest framework.
- Android: Appium primarily uses UiAutomator2, an automation framework provided by Google for testing Android user interfaces. For older Android versions, Appium might utilize UiAutomator. Appium communicates with a bootstrapping application on the Android device, which in turn interacts with the Android system using UiAutomator/UiAutomator2 commands.
- Windows: For automating Windows desktop applications, Appium uses WinAppDriver, Microsoft’s WebDriver implementation for Windows applications. Appium proxies commands to WinAppDriver, which interacts with the Windows UI using the Windows UI Automation API.
4. Mobile Device or Emulator/Simulator: This is the target environment where the mobile application under test resides. The Appium server communicates with the automation framework running on this device or simulated environment to execute the test commands.
Workflow Summary:
- The Appium client (test script) sends a command to the Appium server in the form of a JSON Wire Protocol or W3C WebDriver protocol request.
- The Appium server receives the command and interprets it for the specific mobile platform targeted by the test session.
- The Appium server then forwards the command to the appropriate automation framework (WebDriverAgent for iOS, UiAutomator2 for Android, WinAppDriver for Windows) running on the mobile device or simulator/emulator.
- The automation framework interacts with the mobile operating system and the application’s UI elements to execute the requested action.
- The result of the action is sent back through the automation framework to the Appium server.
- The Appium server then relays the response back to the Appium client.
This layered architecture allows Appium to support multiple platforms using a consistent API, making it a versatile tool for cross-platform mobile test automation. The reliance on the WebDriver protocol also makes it familiar to testers already experienced with web automation using Selenium.
Appium on Android Device
Appium uses the UIAutomator framework (or Selendroid), which is meant for testing the Android user interface to automate applications on Android device testing. The bootstrap.jar file works as a TCP server that sends the test command for acting on the Android device with the help of the UIAutomator or Selendroid framework.
Appium on iOS Device
Similar to the case of Android devices, Appium uses the JSON wire protocol for iOS devices as well. Here, it uses Apple’s UIAutomation API to interact with the user interface elements for automated iOS device testing. The bootstrap.js file works as a TCP server that sends the test command for acting on the iOS device with the help of Apple’s UIAutomation API framework.
What makes Appium so popular?
When it comes to mobile app testing, regardless of whether the application is native, hybrid, or mobile web running on Android, iOS, or Windows, Appium remains the first choice for app automation testing. Its popularity is due to a number of features:
- It is a server and runs in the background
- It can be synchronized with the TestNG testing framework offering a wider range of features
- With an in-built UIAutomator, Appium is capable of producing detailed information logs and has a detailed reporting structure for better analysis of test results better and improved debugging
- It offers the flexibility to write test code in different languages (Java, JavaScript, PHP, Ruby, Python, and C#)
- It offers the reusability of the same code for different device platforms such as iOS, Android, and Windows. This saves a lot of time and effort
- It offers QAs full control of the back-end APIs and databases using the test code. This helps evaluate defects that comes from the back-end APIs or databases
- Testers do not have to modify or recompile the app under test in any way, as Appium uses the standard automation APIs on all platforms. They don’t need to access the source code of the application under test
- It allows testing of mobile applications on emulators or simulators or real devices, offering flexibility to choose their testing device and environment. However, bear in mind that emulators and simulators are highly inadequate for final-stage testing. They cannot replicate many devices features such as low battery or unstable network – which is necessary to optimize the app for unsuitable situations. Only real device testing can offer conclusive, accurate results and make an app suitable for working in real user conditions.
- It offers cross-platform compatibility, enabling the same tests to run on multiple platforms widening the coverage
- It offers real-life monitoring of tests making their execution more robust
- Appium allows parallel execution of test automation scripts on different Android or iOS sessions using UIAutomator, UIAutomation, or Xcode9. This speeds up the testing process and ensures scalability
With so many amazing features, Appium is an automation testing framework that stands out as the best choice for mobile application testing.
How to Install and Configure Appium?
Installing and configuring Appium involves several steps, depending on the platform(s) being targeted for testing. Generally, the process includes:
1. Installing Node.js and npm: Appium server is built on Node.js.
2. Installing Appium Server: Can be installed via npm or by downloading Appium Desktop
npm install -g appium
3. Setting up Platform SDKs: Installing Android SDK and/or Xcode and its command-line tools for Android and iOS respectively.
4. Installing Appium Client Libraries: Installing the client library for the preferred programming language.
pip install Appium-Python-Client for Python
5. Configuring Environment Variables: Setting up necessary environment variables like ANDROID_HOME.
How to get started with Appium
To begin with Appium Testing, start this with the installation process and get the prerequisites ready. Follow the steps below for installation.
Prerequisites of Appium Testing
Download the following components to run Appium tests on Android:
- Appium Jar files for Java
- Latest Appium Client Library
- Appium Server
- Java
- TestNG
- Install Java on the system. Don’t forget to set the environment variables.
- Configure Device with Developer Mode option enabled.
Appium Testing
- To write the Appium Test Script, create a new project in Eclipse. Create the package and class to start writing the test code.
- Write Appium Test Script, and run it.
To get started with the Appium automation mobile application testing, head over to the BrowserStack’s App Automate documentation to get started. Install the prerequisite components, based on the scripting language and framework chosen.
Alternatively, refer to the following tutorials to run Appium tests on Android and iOS devices:
Get Started with Appium for Free
To perform extensive cross-platform testing for mobile apps, try BrowserStack App Automate, which provides cloud-based, Appium testing on thousands of real mobile devices (Android, iOS, Windows, and much more). Our real device cloud allows QAs to access real devices with real operating systems in order to run automated tests via Appium.
Why choose BrowserStack to run Appium Tests?
BrowserStack App Automate is a reliable and scalable cloud-based platform for running Appium tests on over 3500+ real mobile devices and operating systems. This eliminates the need for setting up and maintaining a local device lab, providing instant access to a wide range of testing environments. Key benefits of using BrowserStack for Appium testing include:
- Access to Real Devices: Test on genuine iOS and Android devices for accurate results.
- Scalability: Run tests in parallel across multiple devices and OS versions.
- Simplified Setup: No need to manage complex local infrastructure.
- Pre-installed SDKs and Tools: Ready-to-use testing environment with necessary SDKs and tools.
- Comprehensive Reporting: Detailed test logs, video recordings, and screenshots for easy debugging.
- Integration with CI/CD: Seamless integration with popular Continuous Integration and Continuous Delivery pipelines.
Limitations of Appium
While Appium is a powerful tool, it has certain limitations:
- Limited Support for Non-Standard UI Elements: Automating complex or highly customized UI elements can be challenging.
- Performance Overhead: Interactions might be slightly slower compared to platform-native testing frameworks.
- Setup Complexity: Initial setup and configuration can be intricate, especially for iOS.
Appium Resources
- How to Download and Install Appium
- Top Appium Commands every Developer must know
- Desired Capabilities in Appium
- Effective Locator Strategies in Appium
- How to Run Your First Appium Test Script
- How to run Appium iOS Tests on Real Devices?
- Appium Best Practices Every Developer Must Know
- Effective Locator Strategies in Appium
- How to perform Debugging in Appium
- How to perform Parallel Test Execution in Appium?
- How to Test Flutter Apps Using Appium Automation
- How to set up your Appium Grid
Conclusion
To keep up with the demands of fast and reliable testing that spans over various platforms, devices, and versions, Appium mobile testing is indispensable. Preferred throughout the industry, Appium offers feasibility, flexibility, and cost-friendliness above other testing methods, enabling teams to deliver great user experiences within the continuous delivery approach.