CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-appium-python-client

Python client library for Appium mobile automation framework extending Selenium WebDriver with iOS and Android testing capabilities

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

android-platform.mddocs/

Android Platform

Android-specific capabilities including network management, activity control, SMS simulation, GSM operations, and power management. These features enable comprehensive Android device testing and emulation scenarios.

Capabilities

Activity Management

Control Android activities and query current activity state for navigation and app flow testing.

def start_activity(self, app_package: str, app_activity: str, **opts):
    """
    Start Android activity by package and activity name.
    
    Args:
        app_package (str): Android package name (e.g., 'com.example.app')
        app_activity (str): Activity class name (e.g., '.MainActivity')
        **opts: Optional activity launch parameters
            app_wait_package (str): Package to wait for
            app_wait_activity (str): Activity to wait for
            intent_action (str): Intent action
            intent_category (str): Intent category
            intent_flags (str): Intent flags
            optional_intent_arguments (str): Additional intent arguments
            dont_stop_app_on_reset (bool): Don't stop app on reset
    """

@property
def current_activity(self) -> str:
    """
    Get current Android activity name.
    
    Returns:
        str: Current activity class name
    """

Network Management

Control device network connections including WiFi, mobile data, and network speed simulation.

@property
def network_connection(self) -> int:
    """
    Get current network connection state as bitmask.
    
    Returns:
        int: Network connection bitmask (combination of NetworkMask values)
    """

def set_network_connection(self, connection_type: int):
    """
    Set network connection state.
    
    Args:
        connection_type (int): Network connection type bitmask
            Use ConnectionType constants or NetworkMask combinations
    """

def toggle_wifi(self):
    """Toggle WiFi connection on/off."""

def set_network_speed(self, speed_type: str):
    """
    Set network speed emulation.
    
    Args:
        speed_type (str): Network speed type from NetSpeed constants
    """

SMS Operations

Send SMS messages to the device for testing SMS-related functionality and notifications.

def send_sms(self, phone_number: str, message: str):
    """
    Send SMS message to device.
    
    Args:
        phone_number (str): Source phone number for SMS
        message (str): SMS message content
    """

GSM Operations

Simulate GSM calls and control GSM signal properties for telephony testing.

def set_gsm_call(self, phone_number: str, action: str):
    """
    Simulate GSM call operation.
    
    Args:
        phone_number (str): Phone number for call simulation
        action (str): Call action ('call', 'accept', 'cancel', 'hold')
    """

def set_gsm_signal(self, signal_strength: int):
    """
    Set GSM signal strength.
    
    Args:
        signal_strength (int): Signal strength level (0-4)
            0 = No signal, 4 = Full signal
    """

def set_gsm_voice(self, state: str):
    """
    Set GSM voice state.
    
    Args:
        state (str): Voice state ('unregistered', 'home', 'roaming', 'searching', 'denied', 'off', 'on')
    """

Power Management

Control device power settings including battery level and AC power state for power-related testing.

def set_power_capacity(self, percent: int):
    """
    Set device battery level.
    
    Args:
        percent (int): Battery percentage (0-100)
    """

def set_power_ac(self, ac_state: str):
    """
    Set AC power connection state.
    
    Args:
        ac_state (str): AC power state ('on' or 'off')
    """

Notification Management

Control Android notification panel and system notifications for testing notification-based features.

def open_notifications(self):
    """Open the Android notification panel."""

Usage Examples

Activity Navigation

from appium import webdriver
from appium.options.android import UiAutomator2Options

# Setup
options = UiAutomator2Options()
options.platform_name = "Android"
options.device_name = "Android Emulator"
driver = webdriver.Remote("http://localhost:4723", options=options)

# Start specific activity
driver.start_activity(
    app_package="com.example.myapp",
    app_activity=".MainActivity"
)

# Check current activity
current = driver.current_activity
print(f"Current activity: {current}")

# Start activity with intent extras
driver.start_activity(
    app_package="com.example.myapp",
    app_activity=".SettingsActivity",
    intent_action="android.intent.action.VIEW",
    intent_category="android.intent.category.DEFAULT",
    optional_intent_arguments="--es key value"
)

# Wait for specific activity
driver.start_activity(
    app_package="com.example.myapp", 
    app_activity=".LoadingActivity",
    app_wait_package="com.example.myapp",
    app_wait_activity=".HomeActivity"
)

Network Testing

from appium.webdriver.common.connectiontype import ConnectionType

# Check current network state
current_connection = driver.network_connection
print(f"Current connection: {current_connection}")

# Test app with different network conditions
# No connection
driver.set_network_connection(ConnectionType.NO_CONNECTION)
test_offline_functionality()

# WiFi only
driver.set_network_connection(ConnectionType.WIFI_ONLY)
test_wifi_functionality()

# Data only
driver.set_network_connection(ConnectionType.DATA_ONLY)
test_mobile_data_functionality()

# All networks on
driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
test_full_connectivity()

# Toggle WiFi
driver.toggle_wifi()  # Turn off WiFi
test_data_only_mode()
driver.toggle_wifi()  # Turn WiFi back on

# Simulate different network speeds
from appium.webdriver.extensions.android.network import NetSpeed

speed_tests = [
    NetSpeed.GSM,      # Slow connection
    NetSpeed.EDGE,     # Edge connection  
    NetSpeed.HSDPA,    # 3G connection
    NetSpeed.LTE       # 4G connection
]

for speed in speed_tests:
    driver.set_network_speed(speed)
    print(f"Testing with {speed} network speed")
    test_network_dependent_features()

SMS and Communication Testing

# Send SMS to trigger app notifications
driver.send_sms("+1234567890", "Your verification code is: 123456")

# Wait for SMS to be received and processed
time.sleep(2)

# Check if app processed the SMS
notification_element = driver.find_element("id", "notification_text")
assert "verification code" in notification_element.text.lower()

# Test multiple SMS messages
sms_messages = [
    ("12345", "Test message 1"),
    ("67890", "Test message 2"), 
    ("54321", "Test message 3")
]

for phone, message in sms_messages:
    driver.send_sms(phone, message)
    time.sleep(1)

# Verify app handles multiple SMS
sms_list = driver.find_elements("class", "sms_item")
assert len(sms_list) == 3

GSM and Telephony Testing

# Simulate incoming call
driver.set_gsm_call("+1234567890", "call")

# Check if app responds to incoming call
call_overlay = driver.find_element("id", "incoming_call_overlay")
assert call_overlay.is_displayed()

# Accept the call
driver.set_gsm_call("+1234567890", "accept")

# Test call in progress UI
in_call_ui = driver.find_element("id", "in_call_interface")
assert in_call_ui.is_displayed()

# End the call
driver.set_gsm_call("+1234567890", "cancel")

# Test different signal strengths
signal_levels = [0, 1, 2, 3, 4]  # No signal to full signal

for level in signal_levels:
    driver.set_gsm_signal(level)
    print(f"Testing with signal strength: {level}")
    
    # Check app's response to signal changes
    signal_indicator = driver.find_element("id", "signal_indicator")
    # Verify UI reflects signal strength

# Test roaming scenarios
driver.set_gsm_voice("roaming")
test_roaming_functionality()

driver.set_gsm_voice("home")
test_home_network_functionality()

Power Management Testing

# Test app behavior at different battery levels
battery_levels = [100, 75, 50, 25, 10, 5]

for level in battery_levels:
    driver.set_power_capacity(level)
    print(f"Testing at {level}% battery")
    
    # Check if app shows battery warnings
    if level <= 10:
        battery_warning = driver.find_elements("id", "low_battery_warning")
        assert len(battery_warning) > 0
    
    # Test power-saving features activation
    if level <= 20:
        test_power_saving_mode()

# Test charging states
driver.set_power_ac("on")  # Plugged in
charging_indicator = driver.find_element("id", "charging_status")
assert "charging" in charging_indicator.text.lower()

driver.set_power_ac("off")  # Unplugged
time.sleep(1)
assert "charging" not in charging_indicator.text.lower()

# Test critical battery scenarios
driver.set_power_capacity(1)
driver.set_power_ac("off")
# Verify app handles critical battery appropriately

Comprehensive Android Testing Workflow

def comprehensive_android_test():
    """Complete Android-specific testing workflow."""
    
    # 1. Test with different network conditions
    network_conditions = [
        ConnectionType.NO_CONNECTION,
        ConnectionType.WIFI_ONLY, 
        ConnectionType.DATA_ONLY,
        ConnectionType.ALL_NETWORK_ON
    ]
    
    for condition in network_conditions:
        driver.set_network_connection(condition)
        run_connectivity_tests(condition)
    
    # 2. Test communication features
    driver.send_sms("12345", "Test SMS")
    driver.set_gsm_call("67890", "call")
    driver.set_gsm_call("67890", "accept")
    driver.set_gsm_call("67890", "cancel")
    
    # 3. Test power scenarios
    for battery in [100, 50, 20, 5]:
        driver.set_power_capacity(battery)
        test_battery_level_behavior(battery)
    
    # 4. Test activity navigation
    activities = [
        ".MainActivity",
        ".SettingsActivity", 
        ".ProfileActivity"
    ]
    
    for activity in activities:
        driver.start_activity("com.example.app", activity)
        test_activity_functionality(activity)
    
    # 5. Reset to normal state
    driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
    driver.set_power_capacity(100)
    driver.set_power_ac("on")

def run_connectivity_tests(connection_type):
    """Test app behavior with specific network condition."""
    pass

def test_battery_level_behavior(battery_level):
    """Test app behavior at specific battery level.""" 
    pass

def test_activity_functionality(activity_name):
    """Test specific activity functionality."""
    pass

Types

# Connection type constants
class ConnectionType:
    NO_CONNECTION: int = 0
    AIRPLANE_MODE: int = 1
    WIFI_ONLY: int = 2
    DATA_ONLY: int = 4
    ALL_NETWORK_ON: int = 6

# Network speed constants
class NetSpeed:
    GSM: str = "gsm"        # 14.4 kbps
    GPRS: str = "gprs"      # 56 kbps
    EDGE: str = "edge"      # 118.4 kbps
    UMTS: str = "umts"      # 1920 kbps
    HSDPA: str = "hsdpa"    # 14400 kbps
    LTE: str = "lte"        # 100000 kbps
    EVDO: str = "evdo"      # 750 kbps
    FULL: str = "full"      # No limit

# Network mask constants
class NetworkMask:
    WIFI: int = 2
    DATA: int = 4
    AIRPLANE_MODE: int = 1

# Type definitions
PackageName = str  # Android package name like 'com.example.app'
ActivityName = str  # Activity class name like '.MainActivity'
PhoneNumber = str  # Phone number string
SMSMessage = str   # SMS content
GSMAction = str    # 'call', 'accept', 'cancel', 'hold'
GSMState = str     # 'unregistered', 'home', 'roaming', etc.
SignalStrength = int  # 0-4 signal level
BatteryPercent = int  # 0-100 battery level
PowerState = str   # 'on' or 'off'
NetworkSpeed = str # Network speed identifier

Install with Tessl CLI

npx tessl i tessl/pypi-appium-python-client

docs

advanced-features.md

android-platform.md

application-management.md

configuration-options.md

device-interaction.md

element-location.md

index.md

service-management.md

webdriver-core.md

tile.json