程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python/appium realizes the functions of sliding up and down the app interface of Huawei application mall to open and close the notification bar

編輯:Python
banner=driver.find_element_by_id('com.huawei.appmarket:id/banner_item_image')
ele_size=banner.size
# The height and width of the elements 
ele_height=ele_size['height']
ele_width=ele_size['width']
# Get the coordinates of the upper left corner of the element 
loc=banner.location
# Cross section of calculation starting point / Ordinate 
#start_x1=loc['x']+ele_width*0.2
#start_y1=loc['y']+ele_height*0.5
# Calculate the horizontal direction of the end point / Ordinate 
#end_x1=loc['x']+ele_width*0.8
#end_y1=start_x1
# Sliding method *
#driver.swipe(start_x, start_y, end_x, end_y)
# Sliding method *20( Slide left and right )
# By relative positioning of screen coordinates , It can adapt to many types 
#for i in range(20):
#driver.swipe(start_x1,start_y1,end_x1,end_y1)
#time.sleep(0.5)
# Slide up and down 
start_x=ele_width*0.5
start_y=ele_height*0.8
end_x=start_x
end_y=ele_height*0.2
for i in range(20):
driver.swipe(start_x,start_y,end_x,end_y)
time.sleep(0.5)
# Open the notification bar to call api
driver.open_notifications()
# Close the notification bar to call api
time.sleep(2)
# Close with the return key 
driver.long_press_keycode(4)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved