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)
封装成函数复用

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM