Written By :Appsierra

Wed Nov 08 2023

5 min read

Integrating Mobile Automation With Appium In Python

Home >> Blogs >> Integrating Mobile Automation With Appium In Python
Mobile Automation With Appium In Python

As there is an understanding among testers that getting commenced with mobile automation is difficult. We strongly believe that a tester must possess a broad range of skills. You do not require to be a specialist in all of them, but it is very crucial to have pondered a spectrum of concepts and explored a variation of tools. The context under which you assess will notify you of the particular choice of the testing procedure and test tools to select. The more choices you are familiar with, the better your context-specific option is going to be. 

In this view, we started seeing that mobile testing has become relatively of a niche among testers. Testers are unwilling to get begun with mobile testing, maybe because they think getting started includes a ton of time and action. This blog will look at the python Appium framework, mobile automation using python.

We will also focus on mobile testing with Appium using Python as a programming language and Appium mobile automation testing from basics to the framework. Furthermore, we are concentrating only on the “getting started” stage. The tools your test team utilizes to solve particular and unique problems can extensively differ. Let’s look at the history of the python Appium framework.

History Of Python Appium Framework 

On the eve of Christmas 2013, Selenium officially departed their AndroidDriver and iPhoneDriver in approval of its driver, Selendroid, and Appium. Appium and Python are a great combination of Mobile automation. Python existing as an Interpreted, high-level programming language proposes a quicker development time.

Appium is an open-source tool you can utilize to automate mobile web, mobile native, and mobile hybrid applications on iOS and Android outlets. Appium is “cross-platform” as it enables you to write tests on many platforms like iOS, Android, etc, utilizing the same API. This facilitates a huge or total amount of code reutilization between iOS and Android test suites.

Appium Testing Using Python

This section is a fast start for a primary mobile app automation test utilizing Appium Python testing. The sample project is evolved in Pycharm IDE and for an Android device. 

Following are the requirements below:

  1. The latest edition of Java is required for Android Studio.
  2. Installation of Android Studio with SDK. This is required since ADB gets installed as part of the Android SDK. The ADB utility is proposed to get the device list related to the PC.
  3. Download sample Android application called Eribank using the link https://experitest.s3.amazonaws.com/eribank.apk
  4. Installation of the latest edition of PyCharm.
  5. By connecting the Mobile device to the PC using a USB cable and facilitating the developer mode or USB debugging in the Android device.

Relatable Read: Appium Testing Tutorial

Appium Setup

Here are the following steps to set up Appium on Windows 7 and utilize it with an Android emulator.

1. Download the Recent Appium

The first step is to download the latest Appium and you can run the exe to install the Appium desktop app.

2. Download and Install Android Studio

Once you install the Android Studio mark the AVD Manager is further installed as we are moving to drive our tests on an emulator. Set ANDROID_HOME to be your Android SDK path and put in the tools and platform-tools folders to your PATH variable. 

3. Install the Java JDK

Now install the Java JDK and set JAVA_HOME to your JDK folder

4. Install the Python Client library

There are client libraries in Java, Python, PHP, Ruby, C# and JavaScript, and that support Appium’s additions to the WebDriver strategy. While using Appium, you like to utilize these client libraries rather than your regular WebDriver client. You are now set up.

5. Begin the Android Virtual Device (AVD), Manager

Begin the Android Studio and launch the Android Virtual Device (AVD) Manager by clicking.

Also read: Mobile Testing Appium On Android


Build an emulator with the choices you require and launch it using the start button


6. Start the Appium Server Console

Begin the Appium server console by double-clicking on the Appium file.


7. Launch the Appium Node Server

You should click on the ‘rocket’ icon to launch the Appium node server



Your First Test Using Appium

For this test, we will use the highly suggested Chess Free application built by the UK-based AI Factory. For this post, we will simulate that our test is to launch the application and click on the “PLAY” button.

1. Acquire the .apk for the application under test

We acquired the .apk for Chess Free over here. Copy the chess application to a directory of your preference. 

2. Glance into the AndroidManifest.xml

To compose the test, you require two pieces of data specific to your application:

  • Java package of the Android app you wish to drive
  • The name of the activity for the Android activity you wish to launch your package

You can receive this information by running the subsequent command:

ANDROID_HOME\sdk\build-tools\android-4.4.2>aapt dump badging path_to_apk_file


Another strategy is utilizing the AndroidManifest.xml which is existing in the origin directory of all Android applications and has the data we require. You can utilize Android Studio to discern the AndroidManifest.xml file. Go to Build/Analyze APK and choose your apk. Then you can view the content of the AndroidManifest file.

package=”uk.co.aifactory.chess free” and 


3. Write the Test

Using Python Appium Framework
History Of Python Appium Framework 

Build a test script in $Directory_Of_My_Choice established on the snippet. You should give specific attention to the setup procedure.

The test will:

– launch the app

– Click the ‘PLAY!’ button

import os

import unittest

from appium import web driver

from time import sleep

class ChessAndroidTests(unittest.TestCase):

       def setUp(self):

        “Setup for the test”

        desired_caps = {}

        desired_caps[‘platformName’] = ‘Android’

        desired_caps[‘platformVersion’] = ‘8.0’

        desired_caps[‘deviceName’] = ‘Pixel’

        desired_caps[‘app’] = os.path.abspath(os.path.join(os.path.dirname(__file__),’apps/Chess Free.apk’))

        desired_caps[‘appPackage’] = ‘uk.co.aifactory.chess free’

        desired_caps[‘appActivity’] = ‘.ChessFreeActivity’

        self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, desired_caps)

    def tearDown(self):

        “Tear down the test”


    def test_single_player_mode(self):

               element = self.driver.find_element_by_id(“uk.co.aifactory.chess free:id/ButtonPlay”)




if __name__ == ‘__main__’:

    suite = unittest.TestLoader().loadTestsFromTestCase(ChessAndroidTests)


4. Run the Test

Run the script android_chess.py. The chess application is launched in the test emulator


5. Check the Outcome


Celebrate a little because you only upgrade your skills by a little bit in a very small period!

There you possess it as you have just run your first mobile automated test with Appium and Python. We now dwell in the mobile world more than ever. Further industries are concentrated on building mobile apps for their enterprises. Users presently spend most of their virtual time on their mobile devices utilizing a collection of apps. When the user is interacting with these apps, he or she may be needing a specific level of quality, but with an ever-growing mobile world, this can be difficult.

Suggested Read: Software Testing Services


This is where Test Automation arrives. Since we utilize it to only automate web applications utilizing Selenium. However now, we can carry that knowledge and assign it to mobile using Appium. As we have learned everything about the python Appium framework in this tutorial. If you have any queries or comments do not hesitate to reach out to us. We’ll be happy to help you.

Also Read: Learning Mobile Automation With Appium 

Our Popular Articles