UI Auto常见的定位方式与例子

2019-03-08  本文已影响0人  水漾涟漪penny

常见的定位方式与例子

Android端

1. name定位

name="我的"

2. id定位

id="search_src_text"

3. classname定位

classname="android.widget.EditText"

4. id/name/classname + index 定位

id="rl_container" index="0"

5. xpath定位

"xpath=\"//android.support.v7.widget.RecyclerView[1]/android.widget.LinearLayout[2]/android.widget.RelativeLayout[1]\""

6. 坐标定位

x="816" y="477"

备注:仅限xy_click方法使用

7. 滑动  ab=x轴的1/2,cd=x轴的2/4,ef=y轴的4/5,gh=y轴的1/5,意思是从x轴的1/2到2/4,y轴从4/5到1/5;

上滑: a="1" b="2" c="1" d="2" e="4" f="5" g="1" h="5"

下滑: a="1" b="2" c="1" d="2" e="1" f="5" g="4" h="5"

右滑: a="1" b="5" c="4" d="5" e="1" f="2" g="1" h="2"

左滑: a="4" b="5" c="1" d="5" e="1" f="2" g="1" h="2"

备注:仅限slide_defined方法使用

IOS端,建议都采用谓词方式

1. name定位

iOSNsPredicateString="name='添加朋友'"

iOSNsPredicateString="name contains '信息'"

2. type定位/calssname定位

OSNsPredicateString="type == 'XCUIElementTypeTextView'"

3. value定位

iOSNsPredicateString="value = '请输入密码'"

4. name+type定位

iOSNsPredicateString="type == 'XCUIElementTypeButton' and name = '相册'"

iOSNsPredicateString="type == 'XCUIElementTypeButton' and name contains '确定'"

5. label+type定位

iOSNsPredicateString="type == 'XCUIElementTypeStaticText' and label contains '公告'"

6. value+type定位

iOSNsPredicateString="type == 'XCUIElementTypeTextField' and value contains '字以内的标题'"

7. xpath定位

"xpath=\"//XCUIElementTypeOther[1]/XCUIElementTypeTable[1]/XCUIElementTypeCell[4]\""

"xpath=\"//*[@name='编辑']/..\""

"xpath=\"//*[@name='bjt_toolBarIcon_more_nomal']/..\""

8. 坐标定位

x="816" y="477"

备注:仅限xy_click方法使用

9. 滑动

上滑: a="1" b="2" c="1" d="2" e="4" f="5" g="1" h="5"

下滑: a="1" b="2" c="1" d="2" e="1" f="5" g="4" h="5"

右滑: a="1" b="5" c="4" d="5" e="1" f="2" g="1" h="2"

左滑: a="4" b="5" c="1" d="5" e="1" f="2" g="1" h="2"

备注:仅限slide_defined方法使用

上一篇 下一篇

猜你喜欢

热点阅读