1、启动Appium,启动检查器会话
2、查看应用包名和启动的activity名称,打开cmd输入命令:
aapt dump badging <apk绝对路径>
appActivity:launchable-activity: name=''
appPackage:package: name=''
3、查看手机版本和手机设备名称
adb shell getprop ro.build.version.release #手机android版本
adb devices #设备名称
4、编辑会话信息,然后启动会话
5、代码,启动app然后退出app操作
1 from appium import webdriver
2
3 caps = {}
4 caps["platformName"] = "Android"
5 caps["platformVersion"] = "7.0"
6 caps["devicesName"] = "4YUDU16504012037"
7 caps["appActivity"] = "<启动类名>"
8 caps["appPackage"] = "<package name>"
9 caps["ensureWebviewsHavePages"] = True
10 driver = webdriver.Remote("http://127.0.0.1:8200/wd/hub", caps)
11
12 el1 = driver.find_element_by_id("<id属性>")
13 # 调用click方法、send_keys()方法、键盘或触屏事件
14 el1.click()
15 driver.press_keycode(66)
16 driver.quit()