-
public final class UiViewBuilderClass for building UiAutomator selectors
This class helps to build selectors for UiAutomator views and get their interactions.
-
-
Constructor Summary
Constructors Constructor Description UiViewBuilder()
-
Method Summary
Modifier and Type Method Description final UnitwithIndex(Integer index, Function1<UiViewBuilder, Unit> function)Matches only view at given index, if there are multiple views that matches final UnitwithId(String packageName, String resourceId)Matches the view with given package name and resource id final UnitwithPackage(String packageName)Matches the view with given package name final UnitwithPackage(Pattern packageName)Matches the view with given package name final UnitisEnabled()Matches the view if it is in ENABLED state final UnitisDisabled()Matches the view if it is not in ENABLED state final UnitisChecked()Matches the view if it is in CHECKED state final UnitisNotChecked()Matches the view if it is not in CHECKED state final UnitisCheckable()Matches the view if it is checkable final UnitisNotCheckable()Matches the view if it is not checkable final UnitisClickable()Matches the view if it is clickable final UnitisNotClickable()Matches the view if it is not clickable final UnitisLongClickable()Matches the view if it is long clickable final UnitisNotLongClickable()Matches the view if it is not long clickable final UnitisFocusable()Matches the view if it is focusable final UnitisNotFocusable()Matches the view if it is not focusable final UnitisScrollable()Matches the view if it is scrollable final UnitisNotScrollable()Matches the view if it is not scrollable final UnitisSelected()Matches the view if it is selected final UnitisNotSelected()Matches the view if it is not selected final UnitwithContentDescription(String contentDescription)Matches the view with given content description final UnitwithContentDescription(Pattern contentDescription)Matches the view with given content description final UnitwithText(String text)Matches the view with given text final UnitwithText(Pattern text)Matches the view with given text final UnitwithoutText(String text)Matches if the view does not have a given text final UnitwithAnyText()Matches the view which contains any text final UnitcontainsText(String text)Matches the view which contain given text final UnittextStartsWith(String text)Matches if the view which text starts with given text final UnittextEndsWith(String text)Matches if the view which text ends with given text final UnitwithResourceName(String name)Matches the view with given resource name final UnitwithResourceName(Pattern pattern)Matches the view with given resource name final UnitwithResourceName(String packageName, String name)Matches the view with given resource name final UnitwithDescendant(Function1<UiViewBuilder, Unit> function)Matches the view which has descendant of given matcher final UnitwithDescendant(Integer maxDepth, Function1<UiViewBuilder, Unit> function)Matches the view which has descendant of given matcher with the maximum depth under the element to search the descendant final UnitwithDepth(Integer exactDepth)Matches the view that is at a certain depth final UnitwithDepth(Integer min, Integer max)Matches the view that is in a range of depths final UnitwithMinDepth(Integer min)Matches the view that is at least a certain depth final UnitwithMaxDepth(Integer max)Matches the view that is no more than a certain depth final UnitwithChild(Function1<UiViewBuilder, Unit> function)Matches the view which has child of given matcher final UnitwithClassName(String clazz)Matches the view which class matches given name final UnitwithClassName(Pattern clazz)Matches the view which class matches given name final UnitwithClassName(Class<?> clazz)Matches the view which class matches given name final UnitisInstanceOf(Class<?> clazz)Matches the view by class instance final UnitwithSelector(Function1<BySelector, BySelector> selector)Matches the view with given custom BySelector final UiViewSelectorbuild()Returns combined BySelector with all passed conditions -
-
Method Detail
-
withIndex
final Unit withIndex(Integer index, Function1<UiViewBuilder, Unit> function)
Matches only view at given index, if there are multiple views that matches
- Parameters:
index- Index of the view to matchfunction- UiViewBuilder that will result in matcher
-
withId
final Unit withId(String packageName, String resourceId)
Matches the view with given package name and resource id
- Parameters:
packageName- package name to matchresourceId- id to match
-
withPackage
final Unit withPackage(String packageName)
Matches the view with given package name
- Parameters:
packageName- package name to match
-
withPackage
final Unit withPackage(Pattern packageName)
Matches the view with given package name
- Parameters:
packageName- package name to match
-
isDisabled
final Unit isDisabled()
Matches the view if it is not in ENABLED state
-
isNotChecked
final Unit isNotChecked()
Matches the view if it is not in CHECKED state
-
isCheckable
final Unit isCheckable()
Matches the view if it is checkable
-
isNotCheckable
final Unit isNotCheckable()
Matches the view if it is not checkable
-
isClickable
final Unit isClickable()
Matches the view if it is clickable
-
isNotClickable
final Unit isNotClickable()
Matches the view if it is not clickable
-
isLongClickable
final Unit isLongClickable()
Matches the view if it is long clickable
-
isNotLongClickable
final Unit isNotLongClickable()
Matches the view if it is not long clickable
-
isFocusable
final Unit isFocusable()
Matches the view if it is focusable
-
isNotFocusable
final Unit isNotFocusable()
Matches the view if it is not focusable
-
isScrollable
final Unit isScrollable()
Matches the view if it is scrollable
-
isNotScrollable
final Unit isNotScrollable()
Matches the view if it is not scrollable
-
isSelected
final Unit isSelected()
Matches the view if it is selected
-
isNotSelected
final Unit isNotSelected()
Matches the view if it is not selected
-
withContentDescription
final Unit withContentDescription(String contentDescription)
Matches the view with given content description
- Parameters:
contentDescription- Content description to match
-
withContentDescription
final Unit withContentDescription(Pattern contentDescription)
Matches the view with given content description
- Parameters:
contentDescription- Content description to match
-
withText
final Unit withText(String text)
Matches the view with given text
- Parameters:
text- Text to match
-
withText
final Unit withText(Pattern text)
Matches the view with given text
- Parameters:
text- Text to match
-
withoutText
final Unit withoutText(String text)
Matches if the view does not have a given text
- Parameters:
text- Text to be matched
-
withAnyText
final Unit withAnyText()
Matches the view which contains any text
-
containsText
final Unit containsText(String text)
Matches the view which contain given text
- Parameters:
text- Text to search
-
textStartsWith
final Unit textStartsWith(String text)
Matches if the view which text starts with given text
- Parameters:
text- Text to be matched
-
textEndsWith
final Unit textEndsWith(String text)
Matches if the view which text ends with given text
- Parameters:
text- Text to be matched
-
withResourceName
final Unit withResourceName(String name)
Matches the view with given resource name
- Parameters:
name- Resource name to match
-
withResourceName
final Unit withResourceName(Pattern pattern)
Matches the view with given resource name
- Parameters:
pattern- Pattern for resource name
-
withResourceName
final Unit withResourceName(String packageName, String name)
Matches the view with given resource name
- Parameters:
packageName- package name to matchname- Resource name to match
-
withDescendant
final Unit withDescendant(Function1<UiViewBuilder, Unit> function)
Matches the view which has descendant of given matcher
- Parameters:
function- ViewBuilder which will result in descendant matcher
-
withDescendant
final Unit withDescendant(Integer maxDepth, Function1<UiViewBuilder, Unit> function)
Matches the view which has descendant of given matcher with the maximum depth under the element to search the descendant
- Parameters:
maxDepth- The maximum depth under the element to search the descendantfunction- ViewBuilder which will result in descendant matcher
-
withDepth
final Unit withDepth(Integer exactDepth)
Matches the view that is at a certain depth
- Parameters:
exactDepth- Exact depth
-
withDepth
final Unit withDepth(Integer min, Integer max)
Matches the view that is in a range of depths
- Parameters:
min- Minimal depthmax- Maximal depth
-
withMinDepth
final Unit withMinDepth(Integer min)
Matches the view that is at least a certain depth
- Parameters:
min- Minimal depth
-
withMaxDepth
final Unit withMaxDepth(Integer max)
Matches the view that is no more than a certain depth
- Parameters:
max- Maximal depth
-
withChild
final Unit withChild(Function1<UiViewBuilder, Unit> function)
Matches the view which has child of given matcher
- Parameters:
function- ViewBuilder which will result in child matcher
-
withClassName
final Unit withClassName(String clazz)
Matches the view which class matches given name
- Parameters:
clazz- Class name
-
withClassName
final Unit withClassName(Pattern clazz)
Matches the view which class matches given name
- Parameters:
clazz- Class name
-
withClassName
final Unit withClassName(Class<?> clazz)
Matches the view which class matches given name
- Parameters:
clazz- The class to match
-
isInstanceOf
final Unit isInstanceOf(Class<?> clazz)
Matches the view by class instance
- Parameters:
clazz- Class to match
-
withSelector
final Unit withSelector(Function1<BySelector, BySelector> selector)
Matches the view with given custom BySelector
- Parameters:
selector- BySelector public function
-
build
final UiViewSelector build()
Returns combined BySelector with all passed conditions
-
-
-
-