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)