-
Notifications
You must be signed in to change notification settings - Fork 0
/
mobile_commands_android.py
33 lines (32 loc) · 1.08 KB
/
mobile_commands_android.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
from pprint import pprint
from appium import webdriver
APPIUM = "http://localhost:4723"
CAPS = {
"platformName": "Android",
"appium:options": {
"platformVersion": "14.0", # optional
"deviceName": "Android Emulator",
"automationName": "UiAutomator2",
"appPackage": "com.android.settings",
"appActivity": ".Settings"
}
}
driver = webdriver.Remote(APPIUM, CAPS)
app = "ApiDemos.apk"
app_id = "io.appium.android.apis"
app_act1 = ".view.DateWidgets2"
app_act2 = ".app.FragmentAlertDialog"
try:
driver.remove_app(app)
driver.install_app(app)
driver.activate_app(app_id)
driver.execute_script("mobile: startActivity", {"component": f"{app_id}/{app_act1}"})
time.sleep(3) # for demo only - to observe the activity launch
driver.execute_script("mobile: startActivity", {"component": f"{app_id}/{app_act2}"})
time.sleep(3) # for demo only - to observe the activity launch
driver.terminate_app(app_id)
pprint(driver.execute_script("mobile: deviceInfo"))
finally:
if driver is not None:
driver.quit()