|
本帖最后由 hrthrtlixin 于 2019-4-18 18:08 编辑
直接上码,再说问题,以下代码是测试进入设置,选择显示,选择休眠,然后选择休眠时间为1分钟,1分钟后锁屏,然后点击电源键(26)点亮屏幕,向上滑动解锁 这个流程:
现在的问题是:当选择休眠1分钟测试时,每次到了60秒时就报错:A session is either terminated or not started,但是我测试了15秒,30秒 都没问题,图片是源码打开可以看到
from appium import webdriver
import time
setting = {"platformName":"Android"
,"platformVersion":"7.1.2"
,"deviceName":"L210D01C00112"
,"appPackage":"com.android.settings" #adb shell dumpsys activity activities | grep mFocusedActivity获取app包与启动界面name
,"appActivity":".Settings"
}
#print("测试初始化中,请稍等......")
driver = webdriver.Remote("http://localhost:4723/wd/hub", setting)
print("1分钟后休眠,然后点亮解锁")
time_ = 0
driver.swipe(228,1024,228,651)
driver.find_element_by_xpath("//android.widget.TextView[@text = '显示']").click()
time.sleep(1.5)
driver.find_element_by_xpath("//android.widget.TextView[@text = '休眠']").click()
time.sleep(1.5)
driver.find_element_by_xpath("//android.widget.CheckedTextView[@text = '1分钟']").click()
for i in range(61):
time_ = time_ + 1
time.sleep(1)
print("%s秒" %(time_))
driver.press_keycode(26)
time.sleep(1.5)
driver.swipe(345,1054,345,99)
print("结束") |
|