APP——自动化——python——重置、锁屏、后台运行
# 计算器: C:\Users\del>adb shell dumpsys window w |findstr \/ |findstr name= # mSurface=Surface(name=com.youba.calculate/com.youba.calculate.MainActivity) #adb命令查看包名和启动activity #com.youba.calculate:id/btn_plus + #com.youba.calculate:id/btn_equal = #凤凰网: C:\Users\del>adb shell dumpsys window w |findstr \/ |findstr name= # mSurface=Surface(name=com.ifext.news/com.ifeng.news2.activity.IfengTabMainActivity) #baidu :C:\Users\del>adb shell dumpsys window w |findstr \/ |findstr name= # mSurface=Surface(name=com.baidu.searchbox/com.baidu.searchbox.MainActivity) from appium import webdriver import time desired_caps = { ‘platformName‘: ‘Android‘, #待测试手机的系统 ‘deviceName‘:‘8DF6R17503000072‘, #使用手机或模拟器的类型 ‘platformVersion‘: ‘8.0.0‘, #待测手机系统版本 "unicodeKeyboard":"true", #支持中文输入,会自动安装unicode输入法,默认是false "resetKeyboard":"true", #如果设置了中文输入为true,此设置为自动化退出后,重置输入法到原来状态 "autoGrantPermissions":"true", #获取所有权限 #‘app‘: ‘C:\\Users\\del\\Desktop\\b\\jsq.apk‘, #手机未按照待测app时,设置安装路径、包名、启动activity ‘appPackage‘: ‘com.youba.calculate‘, ‘appActivity‘: ‘com.youba.calculate.MainActivity‘, } driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub‘, desired_caps) time.sleep(5) driver.close_app() #关闭初始化的app time.sleep(5) driver.reset() #重置app(相当于卸载、重新安装) time.sleep(5) driver.background_app(5) #将把当前应用放到后台 5 秒 time.sleep(10) driver.lock(5) #锁屏5秒 time.sleep(10) driver.quit()
相关推荐
liuxudong00 2020-11-19
wwzaqw 2020-11-11
lihaoxiang 2020-11-05
CrossingX 2020-11-04
xuegangic 2020-10-17
86417413 2020-11-25
83206733 2020-11-19
86276537 2020-11-19
83266337 2020-11-19
86256434 2020-11-17
zhouboxiao 2020-11-16
rise 2020-11-22
sssdssxss 2020-11-20
windle 2020-11-10
孙雪峰 2020-10-30
85477104 2020-11-17
xfcyhades 2020-11-20
cheidou 2020-11-19