appium.webdriver.extensions.android package — Python client 1.0 1.0 documentation

# appium.webdriver.extensions.android package

## Submodules

## appium.webdriver.extensions.android.activities module

class Activities(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  property current_activity: str

    Retrieves the current activity running on the device.

    Returns

      The current activity name running on the device

    Return type

      str

  start_activity(app_package: str, app_activity: str, **opts: str) → appium.webdriver.extensions.android.activities.T

    Opens an arbitrary activity during a test. If the activity belongs to another application, that application is started and the activity is opened.

    This is an Android-only method.

    Parameters

      - app_package – The package containing the activity to start.

      - app_activity – The activity to start.

    Keyword Arguments

      - app_wait_package (str) – Begin automation after this package starts.

      - app_wait_activity (str) – Begin automation after this activity starts.

      - intent_action (str) – Intent to start.

      - intent_category (str) – Intent category to start.

      - intent_flags (str) – Flags to send to the intent.

      - optional_intent_arguments (str) – Optional arguments to the intent.

      - dont_stop_app_on_reset (str) – Should the app be stopped on reset?

  wait_activity(activity: str, timeout: int, interval: int = 1) → bool

    Wait for an activity: block until target activity presents or time out.

    This is an Android-only method.

    Parameters

      - activity – target activity

      - timeout – max wait time, in seconds

      - interval – sleep interval between retries, in seconds

    Returns

      True if the target activity is shown

## appium.webdriver.extensions.android.common module

class Common(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  property current_package: str

    Retrieves the current package running on the device.

  end_test_coverage(intent: str, path: str) → Any

    Ends the coverage collection and pull the coverage.ec file from the device.

    Android only. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-coverage.md

    Parameters

      - intent – description of operation to be performed

      - path – path to coverage.ec file to be pulled from the device

    Returns

      TODO

  open_notifications() → appium.webdriver.extensions.android.common.T

    Open notification shade in Android (API Level 18 and above)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Common’]

## appium.webdriver.extensions.android.display module

class Display(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  get_display_density() → int

    Get the display density, Android only

    Returns

      The display density of the Android device(dpi)

    Usage:

      self.driver.get_display_density()

    Returns

      The display density

    Return type

      int

## appium.webdriver.extensions.android.gsm module

class Gsm(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  make_gsm_call(phone_number: str, action: str) → appium.webdriver.extensions.android.gsm.T

    Make GSM call (Emulator only)

    Android only.

    Parameters

      - phone_number – The phone number to call to.

      - action – The call action. A member of the const appium.webdriver.extensions.android.gsm.GsmCallActions

    Usage:

      self.driver.make_gsm_call(‘5551234567’, GsmCallActions.CALL)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Gsm’]

  set_gsm_signal(strength: int) → appium.webdriver.extensions.android.gsm.T

    Set GSM signal strength (Emulator only)

    Android only.

    Parameters

      strength – Signal strength. A member of the enum `appium.webdriver.extensions.android.gsm.GsmSignalStrength`

    Usage:

      self.driver.set_gsm_signal(GsmSignalStrength.GOOD)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Gsm’]

  set_gsm_voice(state: str) → appium.webdriver.extensions.android.gsm.T

    Set GSM voice state (Emulator only)

    Android only.

    Parameters

      state – State of GSM voice. A member of the const appium.webdriver.extensions.android.gsm.GsmVoiceState

    Usage:

      self.driver.set_gsm_voice(GsmVoiceState.HOME)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Gsm’]

class GsmCallActions

  Bases: `object`

  ACCEPT = 'accept'
  CALL = 'call'
  CANCEL = 'cancel'
  HOLD = 'hold'

class GsmSignalStrength

  Bases: `object`

  GOOD = 3
  GREAT = 4
  MODERATE = 2
  NONE_OR_UNKNOWN = 0
  POOR = 1

class GsmVoiceState

  Bases: `object`

  DENIED = 'denied'
  HOME = 'home'
  OFF = 'off'
  ON = 'on'
  ROAMING = 'roaming'
  SEARCHING = 'searching'
  UNREGISTERED = 'unregistered'

## appium.webdriver.extensions.android.nativekey module

class AndroidKey

  Bases: `object`

  A = 29
  ALT_LEFT = 57
  ALT_RIGHT = 58
  APOSTROPHE = 75
  APP_SWITCH = 187
  ASSIST = 219
  AT = 77
  AVR_INPUT = 182
  AVR_POWER = 181
  B = 30
  BACK = 4
  BACKSLASH = 73
  BOOKMARK = 174
  BREAK = 121
  BRIGHTNESS_DOWN = 220
  BRIGHTNESS_UP = 221
  BUTTON_1 = 188
  BUTTON_10 = 197
  BUTTON_11 = 198
  BUTTON_12 = 199
  BUTTON_13 = 200
  BUTTON_14 = 201
  BUTTON_15 = 202
  BUTTON_16 = 203
  BUTTON_2 = 189
  BUTTON_3 = 190
  BUTTON_4 = 191
  BUTTON_5 = 192
  BUTTON_6 = 193
  BUTTON_7 = 194
  BUTTON_8 = 195
  BUTTON_9 = 196
  BUTTON_A = 96
  BUTTON_B = 97
  BUTTON_C = 98
  BUTTON_L1 = 102
  BUTTON_L2 = 104
  BUTTON_MODE = 110
  BUTTON_R1 = 103
  BUTTON_R2 = 105
  BUTTON_SELECT = 109
  BUTTON_START = 108
  BUTTON_THUMBL = 106
  BUTTON_THUMBR = 107
  BUTTON_X = 99
  BUTTON_Y = 100
  BUTTON_Z = 101
  C = 31
  CALCULATOR = 210
  CALENDAR = 208
  CALL = 5
  CAMERA = 27
  CAPS_LOCK = 115
  CAPTIONS = 175
  CHANNEL_DOWN = 167
  CHANNEL_UP = 166
  CLEAR = 28
  COMMA = 55
  CONTACTS = 207
  COPY = 278
  CTRL_LEFT = 113
  CTRL_RIGHT = 114
  CUT = 277
  D = 32
  DEL = 67
  DIGIT_0 = 7
  DIGIT_1 = 8
  DIGIT_2 = 9
  DIGIT_3 = 10
  DIGIT_4 = 11
  DIGIT_5 = 12
  DIGIT_6 = 13
  DIGIT_7 = 14
  DIGIT_8 = 15
  DIGIT_9 = 16
  DPAD_CENTER = 23
  DPAD_DOWN = 20
  DPAD_DOWN_LEFT = 269
  DPAD_DOWN_RIGHT = 271
  DPAD_LEFT = 21
  DPAD_RIGHT = 22
  DPAD_UP = 19
  DPAD_UP_LEFT = 268
  DPAD_UP_RIGHT = 270
  DVR = 173
  E = 33
  EISU = 212
  ENDCALL = 6
  ENTER = 66
  ENVELOPE = 65
  EQUALS = 70
  ESCAPE = 111
  EXPLORER = 64
  F = 34
  F1 = 131
  F10 = 140
  F11 = 141
  F12 = 142
  F2 = 132
  F3 = 133
  F4 = 134
  F5 = 135
  F6 = 136
  F7 = 137
  F8 = 138
  F9 = 139
  FOCUS = 80
  FORWARD = 125
  FORWARD_DEL = 112
  FUNCTION = 119
  G = 35
  GRAVE = 68
  GUIDE = 172
  H = 36
  HEADSETHOOK = 79
  HELP = 259
  HENKAN = 214
  HOME = 3
  I = 37
  INFO = 165
  INSERT = 124
  J = 38
  K = 39
  KANA = 218
  KATAKANA_HIRAGANA = 215
  KEYCODE_ZOOM_IN = 168
  KEYCODE_ZOOM_OUT = 169
  KEY_11 = 227
  KEY_12 = 228
  L = 40
  LANGUAGE_SWITCH = 204
  LAST_CHANNEL = 229
  LEFT_BRACKET = 71
  M = 41
  MANNER_MODE = 205
  MEDIA_AUDIO_TRACK = 222
  MEDIA_CLOSE = 128
  MEDIA_EJECT = 129
  MEDIA_FAST_FORWARD = 90
  MEDIA_NEXT = 87
  MEDIA_PAUSE = 127
  MEDIA_PLAY = 126
  MEDIA_PLAY_PAUSE = 85
  MEDIA_PREVIOUS = 88
  MEDIA_RECORD = 130
  MEDIA_REWIND = 89
  MEDIA_SKIP_BACKWARD = 273
  MEDIA_SKIP_FORWARD = 272
  MEDIA_STEP_BACKWARD = 275
  MEDIA_STEP_FORWARD = 274
  MEDIA_STOP = 86
  MEDIA_TOP_MENU = 226
  MENU = 82
  META_LEFT = 117
  META_RIGHT = 118
  MINUS = 69
  MODE_3D = 206
  MOVE_END = 123
  MOVE_HOME = 122
  MUHENKAN = 213
  MUSIC = 209
  MUTE = 91
  N = 42
  NAVIGATE_IN = 262
  NAVIGATE_NEXT = 261
  NAVIGATE_OUT = 263
  NAVIGATE_PREVIOUS = 260
  NOTIFICATION = 83
  NUM = 78
  NUMPAD_0 = 144
  NUMPAD_1 = 145
  NUMPAD_2 = 146
  NUMPAD_3 = 147
  NUMPAD_4 = 148
  NUMPAD_5 = 149
  NUMPAD_6 = 150
  NUMPAD_7 = 151
  NUMPAD_8 = 152
  NUMPAD_9 = 153
  NUMPAD_ADD = 157
  NUMPAD_COMMA = 159
  NUMPAD_DIVIDE = 154
  NUMPAD_DOT = 158
  NUMPAD_ENTER = 160
  NUMPAD_EQUALS = 161
  NUMPAD_LEFT_PAREN = 162
  NUMPAD_MULTIPLY = 155
  NUMPAD_RIGHT_PAREN = 163
  NUMPAD_SUBTRACT = 156
  NUM_LOCK = 143
  O = 43
  P = 44
  PAGE_DOWN = 93
  PAGE_UP = 92
  PAIRING = 225
  PERIOD = 56
  PICTSYMBOLS = 94
  PLUS = 81
  POUND = 18
  POWER = 26
  PROG_BLUE = 186
  PROG_GREEN = 184
  PROG_RED = 183
  PROG_YELLOW = 185
  Q = 45
  R = 46
  RIGHT_BRACKET = 72
  RO = 217
  S = 47
  SCROLL_LOCK = 116
  SEARCH = 84
  SEMICOLON = 74
  SETTINGS = 176
  SHIFT_LEFT = 59
  SHIFT_RIGHT = 60
  SLASH = 76
  SLEEP = 223
  SOFT_LEFT = 1
  SOFT_RIGHT = 2
  SOFT_SLEEP = 276
  SPACE = 62
  STAR = 17
  STB_INPUT = 180
  STB_POWER = 179
  STEM_1 = 265
  STEM_2 = 266
  STEM_3 = 267
  STEM_PRIMARY = 264
  SWITCH_CHARSET = 95
  SYM = 63
  SYSRQ = 120
  T = 48
  TAB = 61
  TV = 170
  TV_ANTENNA_CABLE = 242
  TV_AUDIO_DESCRIPTION = 252
  TV_AUDIO_DESCRIPTION_MIX_DOWN = 254
  TV_AUDIO_DESCRIPTION_MIX_UP = 253
  TV_CONTENTS_MENU = 256
  TV_DATA_SERVICE = 230
  TV_INPUT = 178
  TV_INPUT_COMPONENT_1 = 249
  TV_INPUT_COMPONENT_2 = 250
  TV_INPUT_COMPOSITE_1 = 247
  TV_INPUT_COMPOSITE_2 = 248
  TV_INPUT_HDMI_1 = 243
  TV_INPUT_HDMI_2 = 244
  TV_INPUT_HDMI_3 = 245
  TV_INPUT_HDMI_4 = 246
  TV_INPUT_VGA_1 = 251
  TV_MEDIA_CONTEXT_MENU = 257
  TV_NETWORK = 241
  TV_NUMBER_ENTRY = 234
  TV_POWER = 177
  TV_RADIO_SERVICE = 232
  TV_SATELLITE = 237
  TV_SATELLITE_BS = 238
  TV_SATELLITE_CS = 239
  TV_SATELLITE_SERVICE = 240
  TV_TELETEXT = 233
  TV_TERRESTRIAL_ANALOG = 235
  TV_TERRESTRIAL_DIGITAL = 236
  TV_TIMER_PROGRAMMING = 258
  TV_ZOOM_MODE = 255
  U = 49
  UNKNOWN = 0
  V = 50
  VOICE_ASSIST = 231
  VOLUME_DOWN = 25
  VOLUME_MUTE = 164
  VOLUME_UP = 24
  W = 51
  WAKEUP = 224
  WINDOW = 171
  X = 52
  Y = 53
  YEN = 216
  Z = 54
  ZENKAKU_HANKAKU = 211
  confirm_buttons = [23, 66, 62, 160]
  gamepad_buttons = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203]
  static is_confirm_key(code: int) → bool

    Returns true if the key will, by default, trigger a click on the focused view.

  static is_gamepad_button(code: int) → bool

    Returns true if the specified nativekey is a gamepad button.

  static is_media_key(code: int) → bool

    Returns true if this key is a media key, which can be send to apps that are interested in media key events.

  static is_system_key(code: int) → bool

    Returns true if the key is a system key, System keys can not be used for menu shortcuts.

  static is_wake_key(code: int) → bool

    Returns true if the key is a wake key.

  media_buttons = [126, 127, 85, 91, 79, 86, 87, 88, 89, 130, 90]
  system_buttons = [82, 2, 3, 4, 5, 6, 24, 25, 164, 91, 26, 79, 126, 127, 85, 86, 87, 88, 89, 130, 90, 27, 80, 84, 220, 221, 222]
  wake_buttons = [4, 82, 224, 225, 265, 266, 267]

## appium.webdriver.extensions.android.network module

class NetSpeed

  Bases: `object`

  EDGE = 'edge'
  EVDO = 'evdo'
  FULL = 'full'
  GPRS = 'gprs'
  GSM = 'gsm'
  HSDPA = 'hsdpa'
  LTE = 'lte'
  SCSD = 'scsd'
  UMTS = 'umts'

class Network(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  property network_connection: int

    Returns an integer bitmask specifying the network connection type.

    Android only. Possible values are available through the enumeration appium.webdriver.ConnectionType

  set_network_connection(connection_type: int) → int

    Sets the network connection type. Android only.

    Possible values:

    > Value (Alias) | Data | Wifi | Airplane Mode
    > --- | --- | --- | ---
    > 0 (None) | 0 | 0 | 0
    > 1 (Airplane Mode) | 0 | 0 | 1
    > 2 (Wifi only) | 0 | 1 | 0
    > 4 (Data only) | 1 | 0 | 0
    > 6 (All network on) | 1 | 1 | 0

    These are available through the enumeration appium.webdriver.ConnectionType

    Parameters

      connection_type – a member of the enum appium.webdriver.ConnectionType

    Returns

      Set network connection type

    Return type

      int

  set_network_speed(speed_type: str) → appium.webdriver.extensions.android.network.T

    Set the network speed emulation.

    Android Emulator only.

    Parameters

      speed_type – The network speed type. A member of the const appium.webdriver.extensions.android.network.NetSpeed.

    Usage:

      self.driver.set_network_speed(NetSpeed.LTE)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Network’]

  toggle_wifi() → appium.webdriver.extensions.android.network.T

    Toggle the wifi on the device, Android only.

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Network’]

## appium.webdriver.extensions.android.performance module

class Performance(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  get_performance_data(package_name: str, data_type: str, data_read_timeout: Optional[int] = None) → List[List[str]]

    Returns the information of the system state which is supported to read as like cpu, memory, network traffic, and battery.

    Android only.

    Parameters

      - package_name – The package name of the application

      - data_type – The type of system state which wants to read. It should be one of the supported performance data types. Check `get_performance_data_types()` for supported types

      - data_read_timeout – The number of attempts to read

    Usage:

      self.driver.get_performance_data(‘my.app.package’, ‘cpuinfo’, 5)

    Returns

      The data along to data_type

  get_performance_data_types() → List

    Returns the information types of the system state which is supported to read as like cpu, memory, network traffic, and battery. Android only.

    Usage:

      self.driver.get_performance_data_types()

    Returns

      Available data types

## appium.webdriver.extensions.android.power module

class Power(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  AC_OFF = 'off'
  AC_ON = 'on'
  set_power_ac(ac_state: str) → appium.webdriver.extensions.android.power.T

    Emulate power state change on the connected emulator.

    Android only.

    Parameters

      ac_state – The power ac state to be set. Use Power.AC_OFF, Power.AC_ON

    Usage:
      self.driver.set_power_ac(Power.AC_OFF)
      self.driver.set_power_ac(Power.AC_ON)
    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Power’]

  set_power_capacity(percent: int) → appium.webdriver.extensions.android.power.T

    Emulate power capacity change on the connected emulator.

    Android only.

    Parameters

      percent – The power capacity to be set. Can be set from 0 to 100

    Usage:

      self.driver.set_power_capacity(50)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Power’]

## appium.webdriver.extensions.android.sms module

class Sms(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  send_sms(phone_number: str, message: str) → appium.webdriver.extensions.android.sms.T

    Emulate send SMS event on the connected emulator.

    Android only.

    Parameters

      - phone_number – The phone number of message sender

      - message – The message to send

    Usage:

      self.driver.send_sms(‘555-123-4567’, ‘Hey lol’)

    Returns

      Self instance

    Return type

      Union[‘WebDriver’, ‘Sms’]

## appium.webdriver.extensions.android.system_bars module

class SystemBars(command_executor='http://127.0.0.1:4444', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, file_detector=None, options: Optional[Union[selenium.webdriver.common.options.BaseOptions, List[selenium.webdriver.common.options.BaseOptions]]] = None)

  Bases: `selenium.webdriver.remote.webdriver.WebDriver`

  get_system_bars() → Dict[str, Dict[str, Union[int, bool]]]

    Retrieve visibility and bounds information of the status and navigation bars.

    Android only.

    Returns

      A dictionary whose keys are
        - statusBar

            - visible

            - x

            - y

            - width

            - height

        - navigationBar

            - visible

            - x

            - y

            - width

            - height

## Module contents