or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-features.mdandroid-platform.mdapplication-management.mdconfiguration-options.mddevice-interaction.mdelement-location.mdindex.mdservice-management.mdwebdriver-core.md

android-platform.mddocs/

0

# Android Platform

1

2

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.

3

4

## Capabilities

5

6

### Activity Management

7

8

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

9

10

```python {.api}

11

def start_activity(self, app_package: str, app_activity: str, **opts):

12

"""

13

Start Android activity by package and activity name.

14

15

Args:

16

app_package (str): Android package name (e.g., 'com.example.app')

17

app_activity (str): Activity class name (e.g., '.MainActivity')

18

**opts: Optional activity launch parameters

19

app_wait_package (str): Package to wait for

20

app_wait_activity (str): Activity to wait for

21

intent_action (str): Intent action

22

intent_category (str): Intent category

23

intent_flags (str): Intent flags

24

optional_intent_arguments (str): Additional intent arguments

25

dont_stop_app_on_reset (bool): Don't stop app on reset

26

"""

27

28

@property

29

def current_activity(self) -> str:

30

"""

31

Get current Android activity name.

32

33

Returns:

34

str: Current activity class name

35

"""

36

```

37

38

### Network Management

39

40

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

41

42

```python {.api}

43

@property

44

def network_connection(self) -> int:

45

"""

46

Get current network connection state as bitmask.

47

48

Returns:

49

int: Network connection bitmask (combination of NetworkMask values)

50

"""

51

52

def set_network_connection(self, connection_type: int):

53

"""

54

Set network connection state.

55

56

Args:

57

connection_type (int): Network connection type bitmask

58

Use ConnectionType constants or NetworkMask combinations

59

"""

60

61

def toggle_wifi(self):

62

"""Toggle WiFi connection on/off."""

63

64

def set_network_speed(self, speed_type: str):

65

"""

66

Set network speed emulation.

67

68

Args:

69

speed_type (str): Network speed type from NetSpeed constants

70

"""

71

```

72

73

### SMS Operations

74

75

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

76

77

```python {.api}

78

def send_sms(self, phone_number: str, message: str):

79

"""

80

Send SMS message to device.

81

82

Args:

83

phone_number (str): Source phone number for SMS

84

message (str): SMS message content

85

"""

86

```

87

88

### GSM Operations

89

90

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

91

92

```python {.api}

93

def set_gsm_call(self, phone_number: str, action: str):

94

"""

95

Simulate GSM call operation.

96

97

Args:

98

phone_number (str): Phone number for call simulation

99

action (str): Call action ('call', 'accept', 'cancel', 'hold')

100

"""

101

102

def set_gsm_signal(self, signal_strength: int):

103

"""

104

Set GSM signal strength.

105

106

Args:

107

signal_strength (int): Signal strength level (0-4)

108

0 = No signal, 4 = Full signal

109

"""

110

111

def set_gsm_voice(self, state: str):

112

"""

113

Set GSM voice state.

114

115

Args:

116

state (str): Voice state ('unregistered', 'home', 'roaming', 'searching', 'denied', 'off', 'on')

117

"""

118

```

119

120

### Power Management

121

122

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

123

124

```python {.api}

125

def set_power_capacity(self, percent: int):

126

"""

127

Set device battery level.

128

129

Args:

130

percent (int): Battery percentage (0-100)

131

"""

132

133

def set_power_ac(self, ac_state: str):

134

"""

135

Set AC power connection state.

136

137

Args:

138

ac_state (str): AC power state ('on' or 'off')

139

"""

140

```

141

142

### Notification Management

143

144

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

145

146

```python {.api}

147

def open_notifications(self):

148

"""Open the Android notification panel."""

149

```

150

151

## Usage Examples

152

153

### Activity Navigation

154

155

```python

156

from appium import webdriver

157

from appium.options.android import UiAutomator2Options

158

159

# Setup

160

options = UiAutomator2Options()

161

options.platform_name = "Android"

162

options.device_name = "Android Emulator"

163

driver = webdriver.Remote("http://localhost:4723", options=options)

164

165

# Start specific activity

166

driver.start_activity(

167

app_package="com.example.myapp",

168

app_activity=".MainActivity"

169

)

170

171

# Check current activity

172

current = driver.current_activity

173

print(f"Current activity: {current}")

174

175

# Start activity with intent extras

176

driver.start_activity(

177

app_package="com.example.myapp",

178

app_activity=".SettingsActivity",

179

intent_action="android.intent.action.VIEW",

180

intent_category="android.intent.category.DEFAULT",

181

optional_intent_arguments="--es key value"

182

)

183

184

# Wait for specific activity

185

driver.start_activity(

186

app_package="com.example.myapp",

187

app_activity=".LoadingActivity",

188

app_wait_package="com.example.myapp",

189

app_wait_activity=".HomeActivity"

190

)

191

```

192

193

### Network Testing

194

195

```python

196

from appium.webdriver.common.connectiontype import ConnectionType

197

198

# Check current network state

199

current_connection = driver.network_connection

200

print(f"Current connection: {current_connection}")

201

202

# Test app with different network conditions

203

# No connection

204

driver.set_network_connection(ConnectionType.NO_CONNECTION)

205

test_offline_functionality()

206

207

# WiFi only

208

driver.set_network_connection(ConnectionType.WIFI_ONLY)

209

test_wifi_functionality()

210

211

# Data only

212

driver.set_network_connection(ConnectionType.DATA_ONLY)

213

test_mobile_data_functionality()

214

215

# All networks on

216

driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)

217

test_full_connectivity()

218

219

# Toggle WiFi

220

driver.toggle_wifi() # Turn off WiFi

221

test_data_only_mode()

222

driver.toggle_wifi() # Turn WiFi back on

223

224

# Simulate different network speeds

225

from appium.webdriver.extensions.android.network import NetSpeed

226

227

speed_tests = [

228

NetSpeed.GSM, # Slow connection

229

NetSpeed.EDGE, # Edge connection

230

NetSpeed.HSDPA, # 3G connection

231

NetSpeed.LTE # 4G connection

232

]

233

234

for speed in speed_tests:

235

driver.set_network_speed(speed)

236

print(f"Testing with {speed} network speed")

237

test_network_dependent_features()

238

```

239

240

### SMS and Communication Testing

241

242

```python

243

# Send SMS to trigger app notifications

244

driver.send_sms("+1234567890", "Your verification code is: 123456")

245

246

# Wait for SMS to be received and processed

247

time.sleep(2)

248

249

# Check if app processed the SMS

250

notification_element = driver.find_element("id", "notification_text")

251

assert "verification code" in notification_element.text.lower()

252

253

# Test multiple SMS messages

254

sms_messages = [

255

("12345", "Test message 1"),

256

("67890", "Test message 2"),

257

("54321", "Test message 3")

258

]

259

260

for phone, message in sms_messages:

261

driver.send_sms(phone, message)

262

time.sleep(1)

263

264

# Verify app handles multiple SMS

265

sms_list = driver.find_elements("class", "sms_item")

266

assert len(sms_list) == 3

267

```

268

269

### GSM and Telephony Testing

270

271

```python

272

# Simulate incoming call

273

driver.set_gsm_call("+1234567890", "call")

274

275

# Check if app responds to incoming call

276

call_overlay = driver.find_element("id", "incoming_call_overlay")

277

assert call_overlay.is_displayed()

278

279

# Accept the call

280

driver.set_gsm_call("+1234567890", "accept")

281

282

# Test call in progress UI

283

in_call_ui = driver.find_element("id", "in_call_interface")

284

assert in_call_ui.is_displayed()

285

286

# End the call

287

driver.set_gsm_call("+1234567890", "cancel")

288

289

# Test different signal strengths

290

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

291

292

for level in signal_levels:

293

driver.set_gsm_signal(level)

294

print(f"Testing with signal strength: {level}")

295

296

# Check app's response to signal changes

297

signal_indicator = driver.find_element("id", "signal_indicator")

298

# Verify UI reflects signal strength

299

300

# Test roaming scenarios

301

driver.set_gsm_voice("roaming")

302

test_roaming_functionality()

303

304

driver.set_gsm_voice("home")

305

test_home_network_functionality()

306

```

307

308

### Power Management Testing

309

310

```python

311

# Test app behavior at different battery levels

312

battery_levels = [100, 75, 50, 25, 10, 5]

313

314

for level in battery_levels:

315

driver.set_power_capacity(level)

316

print(f"Testing at {level}% battery")

317

318

# Check if app shows battery warnings

319

if level <= 10:

320

battery_warning = driver.find_elements("id", "low_battery_warning")

321

assert len(battery_warning) > 0

322

323

# Test power-saving features activation

324

if level <= 20:

325

test_power_saving_mode()

326

327

# Test charging states

328

driver.set_power_ac("on") # Plugged in

329

charging_indicator = driver.find_element("id", "charging_status")

330

assert "charging" in charging_indicator.text.lower()

331

332

driver.set_power_ac("off") # Unplugged

333

time.sleep(1)

334

assert "charging" not in charging_indicator.text.lower()

335

336

# Test critical battery scenarios

337

driver.set_power_capacity(1)

338

driver.set_power_ac("off")

339

# Verify app handles critical battery appropriately

340

```

341

342

### Comprehensive Android Testing Workflow

343

344

```python

345

def comprehensive_android_test():

346

"""Complete Android-specific testing workflow."""

347

348

# 1. Test with different network conditions

349

network_conditions = [

350

ConnectionType.NO_CONNECTION,

351

ConnectionType.WIFI_ONLY,

352

ConnectionType.DATA_ONLY,

353

ConnectionType.ALL_NETWORK_ON

354

]

355

356

for condition in network_conditions:

357

driver.set_network_connection(condition)

358

run_connectivity_tests(condition)

359

360

# 2. Test communication features

361

driver.send_sms("12345", "Test SMS")

362

driver.set_gsm_call("67890", "call")

363

driver.set_gsm_call("67890", "accept")

364

driver.set_gsm_call("67890", "cancel")

365

366

# 3. Test power scenarios

367

for battery in [100, 50, 20, 5]:

368

driver.set_power_capacity(battery)

369

test_battery_level_behavior(battery)

370

371

# 4. Test activity navigation

372

activities = [

373

".MainActivity",

374

".SettingsActivity",

375

".ProfileActivity"

376

]

377

378

for activity in activities:

379

driver.start_activity("com.example.app", activity)

380

test_activity_functionality(activity)

381

382

# 5. Reset to normal state

383

driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)

384

driver.set_power_capacity(100)

385

driver.set_power_ac("on")

386

387

def run_connectivity_tests(connection_type):

388

"""Test app behavior with specific network condition."""

389

pass

390

391

def test_battery_level_behavior(battery_level):

392

"""Test app behavior at specific battery level."""

393

pass

394

395

def test_activity_functionality(activity_name):

396

"""Test specific activity functionality."""

397

pass

398

```

399

400

## Types

401

402

```python {.api}

403

# Connection type constants

404

class ConnectionType:

405

NO_CONNECTION: int = 0

406

AIRPLANE_MODE: int = 1

407

WIFI_ONLY: int = 2

408

DATA_ONLY: int = 4

409

ALL_NETWORK_ON: int = 6

410

411

# Network speed constants

412

class NetSpeed:

413

GSM: str = "gsm" # 14.4 kbps

414

GPRS: str = "gprs" # 56 kbps

415

EDGE: str = "edge" # 118.4 kbps

416

UMTS: str = "umts" # 1920 kbps

417

HSDPA: str = "hsdpa" # 14400 kbps

418

LTE: str = "lte" # 100000 kbps

419

EVDO: str = "evdo" # 750 kbps

420

FULL: str = "full" # No limit

421

422

# Network mask constants

423

class NetworkMask:

424

WIFI: int = 2

425

DATA: int = 4

426

AIRPLANE_MODE: int = 1

427

428

# Type definitions

429

PackageName = str # Android package name like 'com.example.app'

430

ActivityName = str # Activity class name like '.MainActivity'

431

PhoneNumber = str # Phone number string

432

SMSMessage = str # SMS content

433

GSMAction = str # 'call', 'accept', 'cancel', 'hold'

434

GSMState = str # 'unregistered', 'home', 'roaming', etc.

435

SignalStrength = int # 0-4 signal level

436

BatteryPercent = int # 0-100 battery level

437

PowerState = str # 'on' or 'off'

438

NetworkSpeed = str # Network speed identifier

439

```