Understanding Appium Architecture: Key Components Explained

Wasiq Bhamla

Posted On: October 14, 2024

view count20917 Views

Read time15 Min Read

Appium is one of the popular open-source tools to automate mobile applications on both Android and iOS platforms.

To truly harness the power of Appium, it’s essential to understand how it works under the hood. Therefore, understanding the Appium architecture is crucial to leverage its full potential for mobile automation testing.

In this blog, let’s look into the Appium architecture along with examples of combining the different components of Appium to effectively automate mobile applications.

What Is Appium?

Appium is an open-source mobile automation tool that supports UI automation of different platforms like mobile, web, desktop, and smart TV-based applications.

It allows you to write tests for native, hybrid, and mobile web apps using a single API, no matter the platform. Appium supports multiple programming languages like Java, Python, JavaScript, and more, making it flexible for developers and testers.

It doesn’t require you to modify your mobile app or add anything extra, which means you can automate tests without changing how your mobile app works.

How Does Appium Work?

Appium is an extension to Selenium WebDriver, as it also follows W3C standards, which are also known as WebDriver specifications. For web applications, almost all browsers have implemented the automation capability in their browsers by following the WebDriver specifications.

Since Appium also wanted to automate the mobile user interface, they decided to adopt W3C WebDriver specifications. Since the UI of the web and mobile applications are somewhat similar, the user first needs to identify and find the elements on the UI to perform actions on it.

W3C WebDriver specification API provides a consistent set of methods for finding the elements and interacting with them. Thus it reduces the time required by the testers to learn Appium because they are already well versed with Selenium WebDriver.

Info Note

Run Appium tests on real Android and iOS devices. Try LambdaTest Today!

A Deep Dive Into Appium Architecture

Appium consists of different components that work together for the automation of the target mobile application.

Shown below is the Appium v2.x architecture. You can use an Appium client language binding depending on your programming language preference for writing the test script. This Appium client will interact with the Appium server running on your machine or a remote machine by passing the capability options for the target platform.

The Appium server, which is a Node.js API server, will consume those capability options and will redirect the user commands to the platform specific driver instance connected to the Appium server instance depending on the capability options.

Appium Architecture

Appium driver will use the native platform-specific framework to redirect those user commands to those frameworks, which actually perform these user commands on the target devices. In the above diagram of Appium architecture, you can also see that if you configure any Appium plugins with the Appium server, it will also execute those Appium plugin commands while executing your test script-related commands.

Appium is not a single component like it used to be in its initial v1.x. With the release of v2.x, Appium has been decoupled into independent components which helps us to write reliable test scripts. Appium uses platform specific drivers, which use platform-specific native frameworks like XCUITest for the iOS platform and UiAutomator2 for the Android platform, as these frameworks provide great support to interact with the device more efficiently.

Let’s understand each of the Appium components in detail with examples of how to use each of these components and what use cases each of them helps with:

Appium Server

Appium server is a Node.js API server. The server needs to be running on the target machine where the mobile devices are connected. It acts as the point of contact for the automation script where the Appium client bindings would pass in the details of the target device and application via a capability option.

The Appium server would then parse the options provided by the Appium client to determine on which available mobile device should the Appium session be started. To install the Appium server, you must make sure that you have installed Node.js v18.x or above on your machine. The recommended way to install Node.js is by using Node Version Manager (NVM).

To install NVM, run the following command on your terminal:

This will install NVM. Now, you can run the command nvm list to check out all the supported Node.js versions. It is recommended to install v18.x LTS, which is listed by NVM as lts/hydrogen. So, to install the v18.x Node.js, run the following command:

This command will install the latest version of v18.x LTS. Once Node.js is installed, you can now install the Appium server by running the following command on your terminal:

To confirm if Appium has been successfully installed, you can run the command appium -v and check the latest installed version of the Appium server. In this blog on Appium architecture, we use the Appium server version v2.11.1.

To start the Appium server session, execute the following command on your terminal:

This command will start the Appium server session where you can configure your automation script to connect and automate the mobile application. By default, this command will use all the installed Appium drivers.

Appium Drivers

Appium drivers are a bridge between the Appium client and the target device. Appium server basically handles the communication between the Appium client and the Appium driver. The Appium commands that the Appium client executes are redirected to the corresponding Appium driver, which starts the session with the Appium server.

Appium drivers implement the WebDriver specifications API methods. Each driver will be using the native technologies of their respective platform while implementing the driver. For example, the XCUITest driver will be using WebDriverAgent, which is developed using Swift programming language and the native commands of Xcode, and UiAutomator2 will be using Android’s native methods in their respective drivers.

With Appiums v2.x, Appium has completely decoupled the drivers from the actual Appium server package, which we installed earlier. Now, you can only install only those drivers which you actually require.

Let’s check out the list of Appium drivers by using the following command on your terminal:

This command will display all the supported drivers, same is shown in the following screenshot:

Appium Drivers

Now, to install any particular driver, you can run the following command:

In this command, you can provide the driver name displayed in the list command executed earlier by replacing <driver-name> in the above command.

To check if there are any updates for any of the installed drivers, you can execute the following command, and it will list all the drivers mentioning the current installed version and the new version that is available for update:

To update a particular driver, you need to execute the following command on your terminal:

In this command, just replace <driver-name> with the actual name of the driver that you want to update.

To use a particular Appium driver in your Appium server session, you need to provide an additional argument of –use-drivers to the Appium server command, which you saw in the previous section, and provide all the required driver names by separating each driver name by a comma.

For example, the following is the command to start the Appium server session for only Android:

Once you execute the above command, you will see the following output on your terminal:

Appium Drivers

Now, you are ready to connect to this Appium server session using the Appium client of your choice.

Appium Client Libraries

Since Appium is based on W3C WebDriver specification, hence, it implements client-server architecture. The server includes the Appium server, which uses the installed drivers along with any Appium plugins and is responsible for managing the target device under test.

The client that you use for writing your Appium test will be sending the commands to the server over the HTTP network. The server will execute the command and will return the status code to the client in the response, which the client will use to determine if the command was executed successfully by the server or if there was any error.

The commands that the Appium client sends to the Appium server are actually API endpoints for every single command. Since API is language agnostic, it really does not matter which programming language you are using. That’s why Appium has support for multiple client bindings.

To connect to the already running Appium server session with the Appium client, we will use the Appium Java client as an example. Let’s see how to connect our Appium test script to the Appium server.

First, you need to add the Appium Java client dependency in your pom.xml file as shown below:

After this, you can create UiAutomator2Options, which describes the target device along with the application under test. Then, you can use this option to create an Appium session for the already-running Appium server.

Connecting to the Appium server with other client-binding languages can be done in a similar approach.

You don’t need to start the Appium server via the terminal; you can also start the Appium server programmatically by using the Appium client binding.

Let’s see an example using the Appium Java client on how to start the server and connect to that server:

You need to make sure that you start the server by calling the service.start() method before you initialize the driver instance because we are using the service.getUrl() method while initializing the driver, which will return the actual URL where the Appium server got started by our test script.

Appium Plugins

Appium provides a new extensible and optional approach to extend and modify Appium behavior during the live session, thus adding new and customized features for the testers without actually needing to modify the core Appium server. This feature of Appium is known as Appium plugins. This feature was introduced with the release of v2.x of Appium.

With the introduction of the Appium plugin, you can create your implementation of the plugin, which helps you solve a particular problem or introduce a new feature to Appium. If you are not looking to create your own Appium plugin, you can use already created plugins by other contributors or by the core Appium devs.

Some of the useful Appium plugins that you can use are appium-device-farm and appium-dashboard-plugin.

There are some officially maintained plugins that are maintained by the Appium development team, which you can check out by executing the following command on your terminal:

It will display the output as shown below:
Appium Plugins

To install any plugin, even those plugins that are not displayed in the output of the above command, you must execute the following command:

You just need to replace the <plugin-name> with the actual name of the plugin. Every plugin has its documentation updated, which mentions the name of the plugin.

Similar to the Appium driver, you can check if there are any updates available for any installed Appium plugins by executing the following command:

If you want to update any plugin, you can simply execute the following command on your terminal:

This command will install the latest available version of the plugin.

In order to use any plugins, you need to pass an additional argument of –use-plugins to the Appium server command when starting the Appium server session.

For example, check out the following command, which will start the Appium server session for Android devices along with the appium-device-farm plugin:

Did you notice the additional argument of –plugin-device-farm-platform? This argument is plugin-specific.

Subscribe to the LambdaTest YouTube Channel for more such insightful tutorials on Appium.

Appium Inspector

Appium Inspector is one of the useful features of mobile automation that lets you find the element you want to interact with. Appium provides a user interface application that you can use to connect to your target device, install the application under test, and allow you to find the element locator, which later you can use to interact with while automating using the Appium client.

You can download the latest version of Appium Inspector by navigating to their GitHub repository release page. You can select the installer based on your operating system. Once the file is downloaded, execute the file and run the installer to install Appium Inspector on your machine.

After the Appium Inspector is installed, the following screen will be displayed when you first launch it:
Appium Inspector

On this screen, you can set up the Appium capabilities for the target device and the application under test. After setting the capabilities, you can save these capabilities as a preset, which you can use later. One thing to remember here, you must first start the Appium server on your machine before you click on the Start Session button.

After you start the Appium Inspector session on the target device with the application under test, you should see the following screen where you can inspect the elements and find the locators:

Appium Inspector

With Appium Inspector, not only can you find the target element on which you want to perform different types of actions, but you can also perform different types of action commands on the device and emulate different finger gestures on the device screen or an element

Appium Doctor

Setting up your machine for Appium is a complex process, and if you miss any setup properly, you won’t be able to automate the platform. To help the users set up the machine correctly, the Appium ecosystem provides the Appium Doctor command line utility, which checks the setup for individual platforms.

For example, if you want to check the platform-specific setup, you can run the following command on your terminal:

If you want to check the Android setup, replace <driver-name> with an Android driver, i.e., uiautomator2, and for iOS, you can use xcuitest.

Once this command execution is completed, you will see the following output:
Appium Doctor

As you can see, it checks if all the mandatory and optional packages are installed on your machine; if not then it will mention how to install the required or optional packages.

While understanding Appium architecture is crucial, it’s also important to think about where you run your tests. Setting up devices locally can get complicated and expensive, especially when you need to test on different platforms or multiple devices at once.

That’s where LambdaTest comes in. With its AI-powered cloud testing platform, you can easily run your Appium tests on an online device farm without worrying about maintaining hardware or dealing with complex setups. It’s as simple as uploading your test scripts and letting LambdaTest handle the rest. You get access to a wide range of devices, faster test execution, and parallel testing to speed up your release cycles.

Conclusion

It’s amazing to see how Appium has evolved over the last 12 years. With ever growing Appium community and contributors, these features of Appium architecture will enhance as well. Hope this blog helps you understand the Appium architecture and how to use different Appium components to automate mobile applications.

Frequently Asked Questions (FAQs)

What is the framework of Appium?

Appium is a cross-platform, open-source mobile automation framework that allows users to write tests for Android and iOS applications using a single codebase, leveraging platform-specific drivers.

What is the difference between Selenium and Appium architecture?

Selenium is primarily for website and web applications that use WebDriver to communicate with browsers, while Appium uses a client-server model to automate mobile apps through platform-specific drivers like UIAutomator for Android and XCUITest for iOS.

Author Profile Author Profile Author Profile

Author’s Profile

Wasiq Bhamla

Wasiq is a Test Automation specialist having more than 15 years of experience in Manual and Automation testing. He has vast experience in automating Desktop, Web, API, Android, and iOS based applications. He is also an active open source contributor on GitHub, a freelancer, a mentor, and a blogger.

Blogs: 7



linkedintwitter

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free