Appium---android.view.View下拉列表定位


 1 #通过resoure-id知道view
 2 ele=driver.find_element_by_id('com.mymoney:id/first_level_wv')
 3 #获取到view的宽和高----w=360-0=360 ; h=1280-977=303
 4 w=ele.size['width']
 5 h=ele.size['height']
 6 print(w,h)
 7 #获取到view的起始纵坐标----977,其实横坐标为0
 8 y=ele.location['y']
 9 x1=int(w/2)
10 y1=int(h/5*4+y)
11 y2=int(h/5*3+y)
12 print(x1,y1,y2)
13 #连续滑动三次
14 for i in range(3):
15     driver.swipe(x1,y1,x1,y2,1000)
16     sleep(1)
 1 #向上滑动
 2 def swipe_up(driver, element):
 3     # 通过resoure-id知道view
 4     ele = driver.find_element_by_id(element)
 5     # 获取到view的宽和高
 6     w = ele.size['width']
 7     h = ele.size['height']
 8     # 获取到view的起始纵坐标----977,其实横坐标为0
 9     x = ele.location['x']
10     y = ele.location['y']
11     x1 = int(w / 2 + x)
12     y1 = int(h / 5 * 4 + y)
13     y2 = int(h / 5 * 3 + y)
14     return driver.swipe(x1, y1, x1, y2, 1000)
封装成函数复用

 

 

 

 

posted on 2019-07-12 20:27  cherry_ning  阅读(1773)  评论(0编辑  收藏  举报

导航