UiSelector的官方帮助文档
2016-06-24 09:32
531 查看
转:https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html
Specifies the elements in the layout hierarchy for tests to target, filtered by properties such as text value, content-description, class name, and state information. You can also target an element by its location
in a layout hierarchy.
Set the search criteria to match widgets that are checkable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Set the search criteria to match widgets that are currently checked (usually for checkboxes). Typically, using this search criteria alone is not useful. You should also include
additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget,
the first widget in the tree is selected.
Adds a child UiSelector criteria to this selector. Use this selector to narrow the search scope to child widgets under a specific parent widget.
Set the search criteria to match the class property for a widget (for example, "android.widget.Button").
Set the search criteria to match the class property for a widget
(for example, "android.widget.Button").
Set the search criteria to match the class property for a widget,
using a regular expression.
Set the search criteria to match widgets that are clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument. Matching is
case-sensitive.
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must contain the string in your input argument. Matching is case-insensitive.
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument.
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must start with the string in your input argument. Matching is case-insensitive.
Set the search criteria to match widgets that are enabled. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Set the search criteria to match widgets that are focusable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Set the search criteria to match widgets that have focus. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Adds a child UiSelector criteria to this selector which is used to start search from the parent widget. Use this selector to narrow the search scope to sibling widgets as well
all child widgets under a parent.
Set the search criteria to match the widget by its node index in the layout hierarchy. The index value must be 0 or greater. Using the index can be unreliable and should only
be used as a last resort for matching. Instead, consider using the
Set the search criteria to match the widget by its instance number. The instance value must be 0 or greater, where the first instance is 0. For example, to simulate a user click
on the third image that is enabled in a UI screen, you could specify a a search criteria where the instance is 2, the
the image widget class,
and
true. The code would look like this:
Set the search criteria to match widgets that are long-clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as
text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is
selected.
Set the search criteria to match the package name of the application that contains the widget.
Set the search criteria to match the package name of the application that contains the widget.
Set the search criteria to match the given resource ID.
Set the search criteria to match the resource ID of the widget, using a regular expression.
Set the search criteria to match widgets that are scrollable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Set the search criteria to match widgets that are currently selected. Typically, using this search criteria alone is not useful. You should also include additional criteria,
such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in
the tree is selected.
Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app). The text for the element must match exactly with the string
in your input argument. Matching is case-sensitive.
Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument. The matching is case-sensitive.
Set the search criteria to match the visible text displayed in a layout element, using a regular expression. The text in the widget must match exactly with the string in your input
argument.
Set the search criteria to match visible text in a widget that is prefixed by the text parameter. The matching is case-insensitive.
UiSelector
public class UiSelector
extends Object
java.lang.Object | |
↳ | android.support.test.uiautomator.UiSelector |
in a layout hierarchy.
Summary
|
---|
UiSelector() |
| |
---|---|
UiSelector | checkable(boolean val) Set the search criteria to match widgets that are checkable. |
UiSelector | checked(boolean val) Set the search criteria to match widgets that are currently checked (usually for checkboxes). |
UiSelector | childSelector(UiSelector selector) Adds a child UiSelector criteria to this selector. |
UiSelector | className(String className) Set the search criteria to match the class property for a widget (for example, "android.widget.Button"). |
<T>UiSelector | className(Class<T> type) Set the search criteria to match the class property for a widget (for example, "android.widget.Button"). |
UiSelector | classNameMatches(String regex) Set the search criteria to match the class property for a widget, using a regular expression. |
UiSelector | clickable(boolean val) Set the search criteria to match widgets that are clickable. |
UiSelector | description(String desc) Set the search criteria to match the content-description property for a widget. |
UiSelector | descriptionContains(String desc) Set the search criteria to match the content-description property for a widget. |
UiSelector | descriptionMatches(String regex) Set the search criteria to match the content-description property for a widget. |
UiSelector | descriptionStartsWith(String desc) Set the search criteria to match the content-description property for a widget. |
UiSelector | enabled(boolean val) Set the search criteria to match widgets that are enabled. |
UiSelector | focusable(boolean val) Set the search criteria to match widgets that are focusable. |
UiSelector | focused(boolean val) Set the search criteria to match widgets that have focus. |
UiSelector | fromParent(UiSelector selector) Adds a child UiSelector criteria to this selector which is used to start search from the parent widget. |
UiSelector | index(int index) Set the search criteria to match the widget by its node index in the layout hierarchy. |
UiSelector | instance(int instance) Set the search criteria to match the widget by its instance number. |
UiSelector | longClickable(boolean val) Set the search criteria to match widgets that are long-clickable. |
UiSelector | packageName(String name) Set the search criteria to match the package name of the application that contains the widget. |
UiSelector | packageNameMatches(String regex) Set the search criteria to match the package name of the application that contains the widget. |
UiSelector | resourceId(String id) Set the search criteria to match the given resource ID. |
UiSelector | resourceIdMatches(String regex) Set the search criteria to match the resource ID of the widget, using a regular expression. |
UiSelector | scrollable(boolean val) Set the search criteria to match widgets that are scrollable. |
UiSelector | selected(boolean val) Set the search criteria to match widgets that are currently selected. |
UiSelector | text(String text) Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app). |
UiSelector | textContains(String text) Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument. |
UiSelector | textMatches(String regex) Set the search criteria to match the visible text displayed in a layout element, using a regular expression. |
UiSelector | textStartsWith(String text) Set the search criteria to match visible text in a widget that is prefixed by the text parameter. |
String | toString() |
| |
---|---|
UiSelector | cloneSelector() |
|
---|
From class java.lang.Object |
Public constructors
UiSelector
UiSelector ()
Public methods
checkable
UiSelector checkable (boolean val)
Set the search criteria to match widgets that are checkable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
checked
UiSelector checked (boolean val)
Set the search criteria to match widgets that are currently checked (usually for checkboxes). Typically, using this search criteria alone is not useful. You should also include
additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget,
the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
childSelector
UiSelector childSelector (UiSelector selector)
Adds a child UiSelector criteria to this selector. Use this selector to narrow the search scope to child widgets under a specific parent widget.
Returns | |
---|---|
UiSelector | UiSelector with this added search criterion |
className
UiSelector className (String className)
Set the search criteria to match the class property for a widget (for example, "android.widget.Button").
Parameters | |
---|---|
className | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
className
UiSelector className (Class<T> type)
Set the search criteria to match the class property for a widget
(for example, "android.widget.Button").
Parameters | |
---|---|
type | Class: type |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
classNameMatches
UiSelector classNameMatches (String regex)
Set the search criteria to match the class property for a widget,
using a regular expression.
Parameters | |
---|---|
regex | String: a regular expression |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
clickable
UiSelector clickable (boolean val)
Set the search criteria to match widgets that are clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
description
UiSelector description (String desc)
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument. Matching is
case-sensitive.
Parameters | |
---|---|
desc | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
descriptionContains
UiSelector descriptionContains (String desc)
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must contain the string in your input argument. Matching is case-insensitive.
Parameters | |
---|---|
desc | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
descriptionMatches
UiSelector descriptionMatches (String regex)
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument.
Parameters | |
---|---|
regex | String: a regular expression |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
descriptionStartsWith
UiSelector descriptionStartsWith (String desc)
Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an
audio prompt for the widget when the widget is selected. The content-description for the widget must start with the string in your input argument. Matching is case-insensitive.
Parameters | |
---|---|
desc | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
enabled
UiSelector enabled (boolean val)
Set the search criteria to match widgets that are enabled. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
focusable
UiSelector focusable (boolean val)
Set the search criteria to match widgets that are focusable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
focused
UiSelector focused (boolean val)
Set the search criteria to match widgets that have focus. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
fromParent
UiSelector fromParent (UiSelector selector)
Adds a child UiSelector criteria to this selector which is used to start search from the parent widget. Use this selector to narrow the search scope to sibling widgets as well
all child widgets under a parent.
Returns | |
---|---|
UiSelector | UiSelector with this added search criterion |
index
UiSelector index (int index)
Set the search criteria to match the widget by its node index in the layout hierarchy. The index value must be 0 or greater. Using the index can be unreliable and should only
be used as a last resort for matching. Instead, consider using the
instance(int)method.
Parameters | |
---|---|
index | int: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
instance
UiSelector instance (int instance)
Set the search criteria to match the widget by its instance number. The instance value must be 0 or greater, where the first instance is 0. For example, to simulate a user click
on the third image that is enabled in a UI screen, you could specify a a search criteria where the instance is 2, the
className(String)matches
the image widget class,
and
enabled(boolean)is
true. The code would look like this:
new UiSelector().className("android.widget.ImageView") .enabled(true).instance(2);
Parameters | |
---|---|
instance | int: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
longClickable
UiSelector longClickable (boolean val)
Set the search criteria to match widgets that are long-clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as
text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is
selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
packageName
UiSelector packageName (String name)
Set the search criteria to match the package name of the application that contains the widget.
Parameters | |
---|---|
name | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
packageNameMatches
UiSelector packageNameMatches (String regex)
Set the search criteria to match the package name of the application that contains the widget.
Parameters | |
---|---|
regex | String: a regular expression |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
resourceId
UiSelector resourceId (String id)
Set the search criteria to match the given resource ID.
Parameters | |
---|---|
id | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
resourceIdMatches
UiSelector resourceIdMatches (String regex)
Set the search criteria to match the resource ID of the widget, using a regular expression.
Parameters | |
---|---|
regex | String: a regular expression |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
scrollable
UiSelector scrollable (boolean val)
Set the search criteria to match widgets that are scrollable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text,
content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
selected
UiSelector selected (boolean val)
Set the search criteria to match widgets that are currently selected. Typically, using this search criteria alone is not useful. You should also include additional criteria,
such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in
the tree is selected.
Parameters | |
---|---|
val | boolean: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
text
UiSelector text (String text)
Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app). The text for the element must match exactly with the string
in your input argument. Matching is case-sensitive.
Parameters | |
---|---|
text | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
textContains
UiSelector textContains (String text)
Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument. The matching is case-sensitive.
Parameters | |
---|---|
text | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
textMatches
UiSelector textMatches (String regex)
Set the search criteria to match the visible text displayed in a layout element, using a regular expression. The text in the widget must match exactly with the string in your input
argument.
Parameters | |
---|---|
regex | String: a regular expression |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
textStartsWith
UiSelector textStartsWith (String text)
Set the search criteria to match visible text in a widget that is prefixed by the text parameter. The matching is case-insensitive.
Parameters | |
---|---|
text | String: Value to match |
Returns | |
---|---|
UiSelector | UiSelector with the specified search criteria |
toString
String toString ()
Returns | |
---|---|
String |
Protected methods
cloneSelector
UiSelector cloneSelector ()
Returns |
---|
UiSelector |
相关文章推荐
- NGUI自适应
- 实例讲解iOS中的UIPageViewController翻页视图控制器
- iOS UIFont 字体名字大全
- EasyUI在表单提交之前进行验证的实例代码
- 背水一战 Windows 10 (18) - 绑定: 与 Element 绑定, 与 Indexer 绑定, TargetNullValue, FallbackValue
- 机器学习学习笔记 PRML Chapter 2.0 : Prerequisite之Sufficient Statistics
- Angular-ui-route
- ssm框架搭建+easyui增删改查实现
- android FragmentTabHost切换Fragment时避免UI重新加载
- arduino 学习笔记(一)
- QtQuick 全局变量解决ListView嵌套子ListView中访问子model难题
- 用代码创建UIPageControl时,无法显示的问题
- app控件获取之uiautomatorviewer
- EasyUI在表单提交之前进行验证的实例代码
- Leet Code 60 Permutation Sequence - 排列序列 - Java
- Leet Code 62 Unique Paths - 不同路径 - Java
- Leet Code 63 Unique Paths II - 不同路径 - Java
- 传智播客UI设计结束了我脑袋别在裤腰带上的生活
- 大三学生暑假到传智播客培训UI设计,不料竟被坑
- iOS开发 贝塞尔曲线UIBezierPath