appium如何解决授权

2,122 阅读1分钟

1.Appium 打开 App 会自动清除之前登录的帐号信息

desired_caps['noReset'] = True

2.初次启动APP会提示授予权限

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
#selenium里面的显示等待模块(WebDriverWait)和判断模块(expected_conditions)封装定位方法
#通过xpath来定位按钮:始终允许
#权限弹窗-始终允许
#判断弹窗次数,默认给5次
#WebDriverWait里面0.5s判断一次是否有弹窗,1s超时
for i in range(5):
     loc = ("xpath", "//*[@text='始终允许']")
    try:
        e = WebDriverWait(driver, 1, 0.5).until(EC.presence_of_element_located(loc))
        e.click()
        except:
         pass