自动化真机测试代码-----易视云不清缓存登录
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from telnetlib import EC
from appium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from time import sleep
class showappuim():
def myDoUpSet(self):
caps={
"platformName":"Android",
# 安卓-版本
"platformVersion":"12.0.0",
"deviceName":"M2012K11C",
#设备名称
"appPackage":"com.juanvision.EseeNetProj",
#app包名
"appActivity":"com.juanvision.modulelogin.activity.SplashActivity",
#cmd查看获取 启动包
"resetKeyboard":True,
"noReset": True
#不清缓存,登录
}
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
#自动启动手机app
el1 = driver.find_element_by_id("com.juanvision.EseeNetProj:id/user_name_edt")
el1.send_keys("appt17")
el2 = driver.find_element_by_id("com.juanvision.EseeNetProj:id/user_pwd_edt")
el2.send_keys("123456")
el3 = driver.find_element_by_id("com.juanvision.EseeNetProj:id/confirm_btn")
el3.click()
sleep(5)
print('休眠等待5秒')
driver.tap([(868,2258),(932,2276)],500)
#xy点击成功
print('(868,2258),(932,2276)],500 坐标范围和时间ms点击成功响应。')
# 方法一:driver.tap([(x1,y1),(x2,y2)], duration),在指定范围内点击
#
# [(x1,y1),(x2,y2)]:坐标范围
#
# duration:持续时间,单位是ms,默认为None,可以省略
def always_allow(driver, number=5):
#
# fuction:权限弹窗-始终允许
# args:1.传driver上面那个函数 driver
# 2.number,判断弹窗次数,默认给5次
# 其它:
# WebDriverWait里面0.5s判断一次是否有弹窗,1s超时
#
#小米权限弹出的要处理界面
#com.miui.securitycenter:id/pm_network
#com.miui.securitycenter:id/pm_notification
#com.miui.securitycenter:id/pm_oaid
#使 checked =true
for i in range(number):
loc = ("xpath", "//*[@text='始终允许']")
try:
e = WebDriverWait(driver, 1, 0.5).until(EC.presence_of_element_located(loc))
e.click()
#
el11 = driver.find_element_by_id("com.miui.securitycenter:id/pm_oaid")
el11.click()
el12 = driver.find_element_by_id("com.miui.securitycenter:id/pm_notification")
el12.click()
el13 = driver.find_element_by_id("com.miui.securitycenter:id/pm_network")
el13.click()
el14 = driver.find_element_by_id("android:id/button1")
el14.click()
el15 = driver.find_element_by_id("com.juanvision.EseeNetProj:id/agree")
el15.value= True
#赋值true
except:
pass
def exit_myapp(self):
self.driver.quit()
#结束自动化的操作
if __name__ == '__main__':
always_allow( showappuim().myDoUpSet())
代码什么的是青春最美的情书