Monthly Archives: June 2018

Appium Python Client

- - Python, Tutorials

Using Appium with Python

Appium is an open source test automation framework for use with native, hybrid and mobile web apps. It drives iOS, Android, and Windows apps using the WebDriver protocol. While the main purpose of appium is to perform automation testing, it can be utilized for variety of other things too. Appium has client libraries in various languages including Python.


  • Appium Node Server

  • Appium-Python-Client

The node server process usually listens at port 4723. You can customize the port you want the appium to run on using the -p or –port parameter. There are numerous options that you may utilize as per your need. Another useful parameter is –log that can be used to direct the log to a file.

appium --help

The idea behind the Appium-Python-Client is we create a driver that allows us to perform actions on the scope of the application under automation. We specify the capabilities that we want the driver to have. The driver basically maps the methods to the commands and passes it on to the appium process and waits for a http response. It is the adb commands that is being used under the hood for android. The Appium-Python-Client can be thought of as a wrapper.

Following is a simple example that uses Appium-Python-Client
from appium import webdriver
import time

def make_navigation_driver(apk_path, package_name, initial_activity, platform='Android', platform_version='8.1.0', device_id='emulator-5554', server_api='http://localhost:4723/wd/hub', **kwargs):
    :param apk_path:
    :param package_name:
    :param initial_activity:
    :param platform:
    :param platform_version:
    :param device_id:
    :param server_api:
    :param kwargs: Probably will use for setting custom timeout and other capabilities. Implement later?
    desired_caps = {
        'platformName': platform,
        'platformVersion': platform_version,
        'deviceName': device_id,
        # 'app': apk_path, # Saving apk travel time to device since it is already installed on the device.
        'appPackage': package_name,
        'appActivity': initial_activity

    return webdriver.Remote(server_api, desired_caps)

def perform_simple_automation(driver):
    :param driver:
    clickables = driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')

    # navigate to next activity or view via clicking on the first clickable.
    if len(clickables):

if __name__ == '__main__':
    platform = "Android"
    platform_version = "7.1.1"
    device_id = "367e7aa0"
    apk_path = "/Users/bhishan/Downloads/udemy.apk"
    package_name = ""
    initial_activity = ".SplashActivity"
    driver = make_navigation_driver(apk_path, package_name, initial_activity, platform=platform,
                                    platform_version=platform_version, device_id=device_id)


Appium Example Gist