Package 

Class UiViewBuilder


  • 
    public final class UiViewBuilder
    
                        

    Class for building UiAutomator selectors

    This class helps to build selectors for UiAutomator views and get their interactions.

    • Constructor Detail

      • UiViewBuilder

        UiViewBuilder()
    • 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 match
        function - 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 match
        resourceId - 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
      • isEnabled

         final Unit isEnabled()

        Matches the view if it is in ENABLED state

      • isDisabled

         final Unit isDisabled()

        Matches the view if it is not in ENABLED state

      • isChecked

         final Unit isChecked()

        Matches the view if it is in CHECKED state

      • isNotChecked

         final Unit isNotChecked()

        Matches the view if it is not in CHECKED state

      • isSelected

         final Unit isSelected()

        Matches the view if it is 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 match
        name - 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 descendant
        function - 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 depth
        max - 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