python3 uiautomator2 page scrolling, sliding related operations

First, the scroll operation: scroll

1, understand the meaning of: scroll, and coordinate unrelated

 

2, source code examples:

image.png


3, the actual code demonstrates:

# 垂直滚动到页面顶部/横向滚动到最左侧
d(scrollable=True).scroll.toBeginning()
d(scrollable=True).scroll.horiz.toBeginning()
# 垂直滚动到页面最底部/横向滚动到最右侧
d(scrollable=True).scroll.toEnd()
d(scrollable=True).scroll.horiz.toEnd()
# 垂直向后滚动到指定位置/横向向右滚动到指定位置
d(scrollable=True).scroll.to(description="指定位置")
d(scrollable=True).scroll.horiz.to(description="指定位置")
# 垂直向前滚动(横向同理)
d(scrollable=True).scroll.forward()
# 垂直向前滚动到指定位置(横向同理)
d(scrollable=True).scroll.forward.to(description="指定位置")

4 Note: See other cases page scrolling of source code examples, can be freely combined, under normal circumstances can scroll to the page position you want; if the scroll can not scroll to the position you want, use the swipe method, as follows shown

Second, the sliding operation: swipe

1, meaning understood: sliding from point A to point B, as will be appreciated slide the screen
2, source code examples:

 

image.png

 

3, the actual code demonstrates:

# 从sx,sy坐标滑动至ex,ey坐标
d.swipe(sx, sy, ex, ey)

Third, drag and drop: drag

1, meaning understood: A drag to the position B, can be understood as a drag button, similar to the swipe
2, source code examples:

 

image.png

3, the actual code demonstrates:

# 从sx,sy坐标拖拽至ex,ey坐标
d.drag(sx, sy, ex, ey)

 



Author: gz_tester
link: https: //www.jianshu.com/p/bb4435303214
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Published 24 original articles · won praise 30 · views 50000 +

Guess you like

Origin blog.csdn.net/yufen9987/article/details/102986562