Official Python Quickstart Example Produces Warnings

Hi everyone,

while following the official Appium Python quickstart example from the documentation page:
:backhand_index_pointing_right: https://appium.io/docs/en/2.19/quickstart/test-py/

I used this code:

import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy

capabilities = dict(
    platformName='Android',
    automationName='uiautomator2',
    deviceName='Android',
    appPackage='com.android.settings',
    appActivity='.Settings',
    language='en',
    locale='US'
)

appium_server_url = 'http://localhost:4723'

class TestAppium(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))

    def tearDown(self) -> None:
        if self.driver:
            self.driver.quit()

    def test_find_battery(self) -> None:
        el = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
        el.click()

if __name__ == '__main__':
    unittest.main()

When I run this, I get the following warnings:

  • "UiAutomator2Options" is not exported from module "appium.options.android"

  • "Remote" is not exported from module "appium.webdriver"

I’m using:

  • Python: 3.13

  • Appium: 2.19

  • Appium-Python-Client: 5.2.2

If I change the code to the following, the warnings disappear:

import unittest
from appium.webdriver.webdriver import WebDriver
from appium.options.android.uiautomator2.base import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy

options = UiAutomator2Options()
options.platform_name = 'Android'
options.automation_name = 'uiautomator2'
options.device_name = 'Android'
options.app_package = 'com.android.settings'
options.app_activity = '.Settings'
options.language = 'en'
options.locale = 'US'

appium_server_url = 'http://localhost:4723'

class TestAppium(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = WebDriver(appium_server_url, options=options)

    def tearDown(self) -> None:
        if self.driver:
            self.driver.quit()

    def test_find_battery(self) -> None:
        el = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
        el.click()

if __name__ == '__main__':
    unittest.main()

My questions:

  1. Is this the recommended way to write Appium tests in Python now?

  2. Should the documentation be updated, since the official example currently produces warnings?

Thanks in advance for clarifying!