[python]如何理解uiautomator里面的 right,left,up,down 及使用场景

关于Android自动化uiautomator 框架,前面有讲在有些场景下,比如需要在设置界面中将某些选项开关打开或者关闭(前提是这些选项和开关的控件(resourceId,className,text)全部相同,无法进行唯一性区分),使用到了child_by_text()和sibling()方法,下面介绍另一种通过相对的简单的方法可实现相同功能,就是right和left的

 1 #-*- coding:utf-8 -*-
 2 '''
 3 Created on 2018年7月30日
 4 
 5 @author: anyd
 6 '''
 7 import time
 8 from uiautomator import device as d
 9 while True:
10     d(text = 'Adaptive brightness').right(resourceId = 'android:id/switch_widget').click()
11     time.sleep(1)
12     d(text = 'Navigation bar hide').right(resourceId = 'android:id/switch_widget').click()

resourceId = 'android:id/switch_widget'  # 这个是红圈中控件右侧的开关按钮的控件resourceId
原文地址:https://www.cnblogs.com/aziji/p/9389678.html