自動化真機測試代碼-----易視雲不清緩存登錄

# 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())
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章