diff --git a/docs/html/reference/android/support/test/InstrumentationRegistry.html b/docs/html/reference/android/support/test/InstrumentationRegistry.html new file mode 100644 index 0000000000000000000000000000000000000000..fa657d5be6a8618e17c9238d534460d3a836ee04 --- /dev/null +++ b/docs/html/reference/android/support/test/InstrumentationRegistry.html @@ -0,0 +1,1378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +java.lang.Object | +|
↳ | + +android.support.test.InstrumentationRegistry | +
An exposed registry instance that holds a reference to the instrumentation running in the + process and it's arguments. Also provides an easy way for callers to get a hold of + instrumentation, application context and instrumentation arguments Bundle. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a copy of instrumentation arguments Bundle.
+
+
+
+
+
+ | |||||||||||
+ Return the Context of this instrumentation's package.
+
+
+
+
+
+ | |||||||||||
+ Returns the instrumentation currently running.
+
+
+
+
+
+ | |||||||||||
+ Return a Context for the target application being instrumented.
+
+
+
+
+
+ | |||||||||||
+ Records/exposes the instrumentation currently running and stores a copy of the
+ instrumentation arguments Bundle in the registry.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a copy of instrumentation arguments Bundle. Use this to get a Bundle
+ containing the command line arguments passed to Instrumentation
into your test.
+
+ This Bundle is not guaranteed to be present under all instrumentations. +
IllegalStateException + | if no argument Bundle has been registered. + | +
---|
Return the Context of this instrumentation's package. Use this to get a
+ Context
representing getContext()
into your test.
+
Returns the instrumentation currently running. Use this to get an Instrumentation
+ into your test.
IllegalStateException + | if instrumentation hasn't been registered + | +
---|
Return a Context for the target application being instrumented. Use this to get a
+ Context
representing getTargetContext()
into your test.
+
Records/exposes the instrumentation currently running and stores a copy of the + instrumentation arguments Bundle in the registry. +
+ This is a global registry - so be aware of the impact of calling this method! +
instrumentation + | the instrumentation currently running. | +
---|---|
arguments + | the arguments for this application. Null deregisters any existing arguments. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.AmbiguousViewMatcherException.Builder | +
Builder for AmbiguousViewMatcherException
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.AmbiguousViewMatcherException | +
An exception which indicates that a Matcher
+ Contains details about the matcher and the current view hierarchy to aid in debugging.
+
+ Since this is usually an unrecoverable error this exception is a runtime exception.
+
+ References to the view and failing matcher are purposefully not included in the state of this
+ object - since it will most likely be created on the UI thread and thrown on the instrumentation
+ thread, it would be invalid to touch the view on the instrumentation thread. Also the view
+ hierarchy may have changed since exception creation (leading to more confusion).
+
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AmbiguousViewMatcherException.Builder | +
+ Builder for AmbiguousViewMatcherException .
+
+
+
+ |
+
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.AppNotIdleException | +
An exception which indicates that the App has not become idle even after the specified duration. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Creates a new AppNotIdleException suitable for erroring out a test case.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Creates a new AppNotIdleException suitable for erroring out a test case. + + This should be called only from the main thread if the app does not idle out within the + specified duration.
idleConditions + | list of idleConditions that failed to become idle. | +
---|---|
loopCount + | number of times it was tried to check if they became idle. | +
seconds + | number of seconds that was tried before giving up. | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.DataInteraction | +
An interface to interact with data displayed in AdapterViews. +
+ This interface builds on top of ViewInteraction
and should be the preferred way to
+ interact with elements displayed inside AdapterViews.
+
+ This is necessary because an AdapterView may not load all the data held by its Adapter into the + view hierarchy until a user interaction makes it necessary. Also it is more fluent / less brittle + to match upon the data object being rendered into the display then the rendering itself. +
++ By default, a DataInteraction takes place against any AdapterView found within the current + screen, if you have multiple AdapterView objects displayed, you will need to narrow the selection + by using the inAdapterView method. +
++ The check and perform method operate on the top level child of the adapter view, if you need to + operate on a subview (eg: a Button within the list) use the onChildView method before calling + perform or check. +
+ + + + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Selects the view which matches the nth position on the adapter
+ based on the data matcher.
+
+
+
+
+
+ | |||||||||||
+ Performs an assertion on the state of the view after we force the data to be loaded.
+
+
+
+
+
+ | |||||||||||
+ Selects a particular adapter view to operate on, by default we operate on any adapter view
+ on the screen.
+
+
+
+
+
+ | |||||||||||
+ Causes this data interaction to work within the Root specified by the given root matcher.
+
+
+
+
+
+ | |||||||||||
+ Causes perform and check methods to take place on a specific child view of the view returned
+ by Adapter.getView()
+
+
+
+
+
+
+ | |||||||||||
+ Performs an action on the view after we force the data to be loaded.
+
+
+
+
+
+ | |||||||||||
+ Use a different AdapterViewProtocol if the Adapter implementation does not
+ satisfy the AdapterView contract like (@code ExpandableListView)
+
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Selects the view which matches the nth position on the adapter + based on the data matcher. +
Performs an assertion on the state of the view after we force the data to be loaded.
ViewInteraction
for more assertions or actions.
+Selects a particular adapter view to operate on, by default we operate on any adapter view + on the screen. +
Causes this data interaction to work within the Root specified by the given root matcher. +
Causes perform and check methods to take place on a specific child view of the view returned + by Adapter.getView() +
Performs an action on the view after we force the data to be loaded.
ViewInteraction
for more assertions or actions.
+Use a different AdapterViewProtocol if the Adapter implementation does not + satisfy the AdapterView contract like (@code ExpandableListView) +
java.lang.Object | +|
↳ | + +android.support.test.espresso.Espresso | +
Entry point to the Espresso framework. Test authors can initiate testing by using one of the on* + methods (e.g. onView) or perform top-level user actions (e.g. pressBack). +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Closes soft keyboard if open.
+
+
+
+
+
+ | |||||||||||
+ Returns a list of all currently registered
+
+ IdlingResource s.
+
+
+
+ | |||||||||||
+ Creates an
+
+ DataInteraction for a data object displayed by the application.
+
+
+
+ | |||||||||||
+ Creates a
+
+ ViewInteraction for a given view.
+
+
+
+ | |||||||||||
+ Opens the overflow menu displayed within an ActionBar.
+
+
+
+
+
+ | |||||||||||
+ Opens the overflow menu displayed in the contextual options of an ActionMode.
+
+
+
+
+
+ | |||||||||||
+ Press on the back button.
+
+
+
+
+
+ | |||||||||||
+ Registers one or more
+
+ IdlingResource s with the framework.
+
+
+
+ | |||||||||||
+ Registers a Looper for idle checking with the framework.
+
+
+
+
+
+ | |||||||||||
+ Registers a Looper for idle checking with the framework.
+
+
+
+
+
+ | |||||||||||
+ Changes the default
+
+ FailureHandler to the given one.
+
+
+
+ | |||||||||||
+ Unregisters one or more
+
+ IdlingResource s.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Closes soft keyboard if open. +
Returns a list of all currently registered IdlingResource
s.
+
Creates an DataInteraction
for a data object displayed by the application. Use this
+ method to load (into the view hierarchy) items from AdapterView widgets (e.g. ListView).
dataMatcher + | a matcher used to find the data object. + | +
---|
Creates a ViewInteraction
for a given view. Note: the view has
+ to be part of the view hierarchy. This may not be the case if it is rendered as part of
+ an AdapterView (e.g. ListView). If this is the case, use Espresso.onData to load the view
+ first.
viewMatcher + | used to select the view. | +
---|
Opens the overflow menu displayed within an ActionBar. + +
This works with both native and SherlockActionBar ActionBars. + +
Note the significant differences of UX between ActionMode and ActionBars with respect to + overflows. If a hardware menu key is present, the overflow icon is never displayed in + ActionBars and can only be interacted with via menu key presses. +
Opens the overflow menu displayed in the contextual options of an ActionMode. + +
This works with both native and SherlockActionBar action modes. + +
Note the significant difference in UX between ActionMode and ActionBar overflows - + ActionMode will always present an overflow icon and that icon only responds to clicks. + The menu button (if present) has no impact on it. +
Press on the back button.
PerformException + | if currently displayed activity is root activity, since pressing back + button would result in application closing. + | +
---|
Registers one or more IdlingResource
s with the framework. It is expected, although not
+ strictly required, that this method will be called at test setup time prior to any interaction
+ with the application under test. When registering more than one resource, ensure that each has
+ a unique name. If any of the given resources is already registered, a warning is logged.
Registers a Looper for idle checking with the framework. This is intended for use with + non-UI thread loopers. + +
This method allows the caller to consider Thread.State.WAIT to be 'idle'. + +
This is useful in the case where a looper is sending a message to the UI thread + synchronously through a wait/notify mechanism.
IllegalArgumentException + | if looper is the main looper. + | +
---|
Registers a Looper for idle checking with the framework. This is intended for use with + non-UI thread loopers.
IllegalArgumentException + | if looper is the main looper. + | +
---|
Changes the default FailureHandler
to the given one.
+
Unregisters one or more IdlingResource
s. If any of the given resources are not already
+ registered, a warning is logged.
android.support.test.espresso.EspressoException | +
+
+ ![]()
+
+
+
+
+ AmbiguousViewMatcherException,
+
+ AppNotIdleException,
+
+ IdlingResourceTimeoutException,
+
+ InjectEventSecurityException,
+
+ NoActivityResumedException,
+
+ NoMatchingRootException,
+
+ NoMatchingViewException,
+
+ PerformException
+
+
+
+
+ |
Used for identifying an exception as coming from the Espresso
framework.
+
android.support.test.espresso.FailureHandler | +
+
+ ![]()
+
+
+
+
+ DefaultFailureHandler
+
+
+
+
+ |
Handles failures that happen during test execution. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Handle the given error in a manner that makes sense to the environment in which the test is
+ executed (e.g.
+
+
+
+
+
+ |
Handle the given error in a manner that makes sense to the environment in which the test is + executed (e.g. take a screenshot, output extra debug info, etc). Upon handling, most handlers + will choose to propagate the error. +
java.lang.Object | +|
↳ | + +android.support.test.espresso.GraphHolder | +
Holds Espresso's ObjectGraph. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.IdlingPolicies | +
Allows users fine grain control over idling policies. + + Espresso's default idling policies are suitable for most usecases - however + certain execution environments (like the ARM emulator) might be very slow. + This class allows users the ability to adjust defaults to sensible values + for their environments. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Updates the IdlingPolicy used by IdlingResourceRegistry to determine when IdlingResources
+ timeout.
+
+
+
+
+
+ | |||||||||||
+ Updates the IdlingPolicy used in UiController.loopUntil to detect AppNotIdleExceptions.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Updates the IdlingPolicy used by IdlingResourceRegistry to determine when IdlingResources + timeout.
timeout + | the timeout before an IdlingResourceTimeoutException is created. | +
---|---|
unit + | the unit of the timeout value. + | +
Updates the IdlingPolicy used in UiController.loopUntil to detect AppNotIdleExceptions.
timeout + | the timeout before an AppNotIdleException is created. | +
---|---|
unit + | the unit of the timeout value. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.IdlingPolicy | +
Allows users to control idling idleTimeouts in Espresso. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ The amount of time the policy allows a resource to be non-idle.
+
+
+
+
+
+ | |||||||||||
+ The unit for {@linkgetIdleTimeout }.
+
+
+
+
+
+ | |||||||||||
+ Invoked when the idle idleTimeout has been exceeded.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
The amount of time the policy allows a resource to be non-idle. +
The unit for {@linkgetIdleTimeout }. +
Invoked when the idle idleTimeout has been exceeded.
busyResources + | the resources that are not idle. | +
---|---|
message + | an additional message to include in an exception. + | +
android.support.test.espresso.IdlingResource.ResourceCallback | +
Registered by an IdlingResource
to notify Espresso of a transition to idle.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Called when the resource goes from busy to idle.
+
+
+
+
+
+ |
Called when the resource goes from busy to idle. +
android.support.test.espresso.IdlingResource | +
+
+ ![]()
+
+
+
+
+ CountingIdlingResource
+
+
+
+
+ |
Represents a resource of an application under test which can cause asynchronous background work
+ to happen during test execution (e.g. an intent service that processes a button click). By
+ default, Espresso
synchronizes all view operations with the UI thread as well as
+ AsyncTasks; however, it has no way of doing so with "hand-made" resources. In such cases, test
+ authors can register the custom resource and Espresso
will wait for the resource to
+ become idle prior to executing a view operation.
+
+ Important Note: it is assumed that the resource stays idle most of the time.
+
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
IdlingResource.ResourceCallback | +
+ Registered by an IdlingResource to notify Espresso of a transition to idle.
+
+
+
+ |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns the name of the resources (used for logging and idempotency of registration).
+
+
+
+
+
+ | |||||||||||
+ Returns
+
+ true if resource is currently idle.
+
+
+
+ | |||||||||||
+ Registers the given
+
+ IdlingResource.ResourceCallback with the resource.
+
+
+
+ |
Returns the name of the resources (used for logging and idempotency of registration). +
Returns true
if resource is currently idle. Espresso will always call this
+ method from the main thread, therefore it should be non-blocking and return immediately.
+
Registers the given IdlingResource.ResourceCallback
with the resource. Espresso will call this method:
+
IdlingResource.ResourceCallback
so it can be notified asynchronously
+ that your resource is idle
+ java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.IdlingResourceTimeoutException | +
Indicates that an IdlingResource
, which has been registered with the framework, has not
+ idled within the allowed time.
+
+ Since it is not safe to proceed with test execution while the registered resource is busy (as it
+ is likely to cause inconsistent results in the test), this is an unrecoverable error. The test
+ author should verify that the IdlingResource
interface has been implemented correctly.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|||
↳ | + +java.lang.Throwable | +||
+ + | ↳ | + +java.lang.Exception | +|
+ + | + + | ↳ | + +android.support.test.espresso.InjectEventSecurityException | +
An checked Exception
indicating that event injection failed with a
+ SecurityException
.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.NoActivityResumedException | +
An exception which indicates that there are no activities in stage RESUMED. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.NoMatchingRootException | +
Indicates that a given matcher did not match any Root
s (windows) from those that are
+ currently available.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.NoMatchingViewException.Builder | +
Builder for NoMatchingViewException
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.NoMatchingViewException | +
Indicates that a given matcher did not match any elements in the view hierarchy. +
+ Contains details about the matcher and the current view hierarchy to aid in debugging. +
++ Since this is usually an unrecoverable error this exception is a runtime exception. +
++ References to the view and failing matcher are purposefully not included in the state of this + object - since it will most likely be created on the UI thread and thrown on the instrumentation + thread, it would be invalid to touch the view on the instrumentation thread. Also the view + hierarchy may have changed since exception creation (leading to more confusion). +
+ + + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NoMatchingViewException.Builder | +
+ Builder for NoMatchingViewException .
+
+
+
+ |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a string description of the ViewMatcher that did not match any view
+ in the hierarchy.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Returns a string description of the ViewMatcher that did not match any view + in the hierarchy. +
java.lang.Object | +|
↳ | + +android.support.test.espresso.PerformException.Builder | +
Builder for PerformException
.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.espresso.PerformException | +
Indicates that an exception occurred while performing a ViewAction on the UI thread.
+
+ A description of the ViewAction
, the view being performed on and the cause are included
+ in the error. Note: FailureHandler
s can mutate the exception later to make it more user
+ friendly.
+
+ This is generally not recoverable so it is thrown on the instrumentation thread.
+
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PerformException.Builder | +
+ Builder for PerformException .
+
+
+
+ |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.Root.Builder | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.Root | +
Represents a root view in the application and optionally the layout params of the window holding + it. + + This class is used internally to determine which view root to run user provided matchers against + it is not part of the public api. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Root.Builder | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
android.support.test.espresso.UiController | +
Provides base-level UI operations (such as injection of MotionEvent
s) that can be used to
+ build user actions such as clicks, scrolls, swipes, etc. This replaces parts of the android
+ Instrumentation class that provides similar functionality. However, it provides a more advanced
+ synchronization mechanism for test actions. The key differentiators are:
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Injects a key event into the application.
+
+
+
+
+
+ | |||||||||||
+ Injects a motion event into the application.
+
+
+
+
+
+ | |||||||||||
+ Types a string into the application using series of
+
+ KeyEvent s.
+
+
+
+ | |||||||||||
+ Loops the main thread for a specified period of time.
+
+
+
+
+
+ | |||||||||||
+ Loops the main thread until the application goes idle.
+
+
+
+
+
+ |
Injects a key event into the application.
event + | the (non-null!) event to inject | +
---|
InjectEventSecurityException + | if the event couldn't be injected because it would + interact with another application. + | +
---|
Injects a motion event into the application.
event + | the (non-null!) event to inject | +
---|
InjectEventSecurityException + | if the event couldn't be injected because it would + interact with another application. + | +
---|
Types a string into the application using series of KeyEvent
s. It is up to the
+ implementor to decide how to map the string to KeyEvent
objects. if you need specific
+ control over the key events generated use injectKeyEvent(KeyEvent)
.
str + | the (non-null!) string to type | +
---|
InjectEventSecurityException + | if the events couldn't be injected because it would + interact with another application. + | +
---|
Loops the main thread for a specified period of time. + + Control may not return immediately, instead it'll return after the time has passed and the + queue is in an idle state again.
millisDelay + | time to spend in looping the main thread + | +
---|
Loops the main thread until the application goes idle. + + An empty task is immediately inserted into the task queue to ensure that if we're idle at this + moment we'll return instantly. +
android.support.test.espresso.ViewAction | +
+
+ ![]()
+
+
+
+
+ AdapterDataLoaderAction,
+
+ CloseKeyboardAction,
+
+ EditorAction,
+
+ GeneralClickAction,
+
+ GeneralSwipeAction,
+
+ KeyEventAction,
+
+ OpenLinkAction,
+
+ RecyclerViewActions.PositionableRecyclerViewAction,
+
+ ReplaceTextAction,
+
+ ScrollToAction,
+
+ TypeTextAction
+
+
+
+
+ |
Responsible for performing an interaction on the given View element.
+
+ This is part of the test framework public API - developers are free to write their own ViewAction + implementations when necessary. When implementing a new ViewAction, follow these rules: +
getConstraints
.
+ Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
android.support.test.espresso.ViewAssertion | +
Responsible for performing assertions on a View element.
+
+ This is considered part of the test framework public API - developers are free to write their own + assertions as long as they meet the following requirements: +
+ Strongly consider using a existing ViewAssertion via the ViewAssertions utility class before + writing your own assertion. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Checks the state of the given view (if such a view is present).
+
+
+
+
+
+ |
Checks the state of the given view (if such a view is present).
view + | the view, if one was found during the view interaction or null if it was not + (which may be an acceptable option for an assertion) | +
---|---|
noViewFoundException + | an exception detailing why the view could not be found or null if + the view was found + | +
android.support.test.espresso.ViewFinder | +
+
+ ![]()
+
+
+
+
+ ViewFinderImpl
+
+
+
+
+ |
Uses matchers to locate particular views within the view hierarchy. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Immediately locates a single view within the provided view hierarchy.
+
+
+
+
+
+ |
Immediately locates a single view within the provided view hierarchy. + + If multiple views match, or if no views match the appropriate exception is thrown.
AmbiguousViewMatcherException + | when multiple views match | +
---|---|
NoMatchingViewException + | when no views match. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.ViewInteraction | +
Provides the primary interface for test authors to perform actions or asserts on views. +
+ Each interaction is associated with a view identified by a view matcher. All view actions and + asserts are performed on the UI thread (thus ensuring sequential execution). The same goes for + retrieval of views (this is done to ensure that view state is "fresh" prior to execution of each + operation). +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Checks the given
+
+ ViewAssertion on the the view selected by the current view matcher.
+
+
+
+ | |||||||||||
+ Makes this ViewInteraction scoped to the root selected by the given root matcher.
+
+
+
+
+
+ | |||||||||||
+ Performs the given action(s) on the view selected by the current view matcher.
+
+
+
+
+
+ | |||||||||||
+ Replaces the default failure handler (@see Espresso.setFailureHandler) with a custom
+ failurehandler for this particular interaction.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Checks the given ViewAssertion
on the the view selected by the current view matcher.
viewAssert + | the assertion to check. | +
---|
Makes this ViewInteraction scoped to the root selected by the given root matcher. +
Performs the given action(s) on the view selected by the current view matcher. If more than one + action is provided, actions are executed in the order provided with precondition checks running + prior to each action.
viewActions + | one or more actions to execute. | +
---|
Replaces the default failure handler (@see Espresso.setFailureHandler) with a custom + failurehandler for this particular interaction.
failureHandler + | a non-null failurehandler to use to report failures. | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.AdapterDataLoaderAction | +
Forces an AdapterView to ensure that the data matching a provided data matcher + is loaded into the current view hierarchy. + +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.AdapterViewProtocol.AdaptedData.Builder | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.AdapterViewProtocol.AdaptedData | +
A holder that associates a data object from an AdapterView with a token the + AdapterViewProtocol can use to force that data object to be rendered as a child or deeper + descendant of the adapter view. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AdapterViewProtocol.AdaptedData.Builder | ++ + + + + | +
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
data | +
+
+ This field is deprecated.
+ use getData() instead.
+
+
+
+
+ |
+ ||||||||||
opaqueToken | ++ A token the implementor of AdapterViewProtocol can use to force the adapterView to display + this data object as a child or deeper descendant in it. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
+
+ This field is deprecated.
+ use getData()
instead.
+
+
One of the objects the AdapterView is exposing to the user.
A token the implementor of AdapterViewProtocol can use to force the adapterView to display + this data object as a child or deeper descendant in it. Equal opaqueToken point to the same + data object on the AdapterView. +
android.support.test.espresso.action.AdapterViewProtocol.DataFunction | +
A custom function that is applied when getData()
is executed.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
android.support.test.espresso.action.AdapterViewProtocol | +
A sadly necessary layer of indirection to interact with AdapterViews. +
+ Generally any subclass should respect the contracts and behaviors of its superclass. Otherwise + it becomes impossible to work generically with objects that all claim to share a supertype - you + need special cases to perform the same operation 'owned' by the supertype for each sub-type. The + 'is - a' relationship is broken. +
+ ++ Android breaks the Liskov substitution principal with ExpandableListView - you can't use + getAdapter(), getItemAtPosition(), and other methods common to AdapterViews on an + ExpandableListView because an ExpandableListView isn't an adapterView - they just share a lot of + code. +
+ ++ This interface exists to work around this wart (which sadly is copied in other projects too) and + lets the implementor translate Espresso's needs and manipulations of the AdapterView into calls + that make sense for the given subtype and context. +
+ ++ If you have to implement this to talk to widgets your own project defines - I'm sorry. +
+ +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AdapterViewProtocol.AdaptedData | ++ A holder that associates a data object from an AdapterView with a token the + AdapterViewProtocol can use to force that data object to be rendered as a child or deeper + descendant of the adapter view. + + + + | +||||||||||
AdapterViewProtocol.DataFunction | +
+ A custom function that is applied when getData() is executed.
+
+
+
+ |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns all data this AdapterViewProtocol can find within the given AdapterView.
+
+
+
+
+
+ | |||||||||||
+ Returns the data object this particular view is rendering if possible.
+
+
+
+
+
+ | |||||||||||
+ Indicates whether or not there now exists a descendant view within adapterView that
+ is rendering this data.
+
+
+
+
+
+ | |||||||||||
+ Requests that a particular piece of data held in this AdapterView is actually rendered by it.
+
+
+
+
+
+ |
Returns all data this AdapterViewProtocol can find within the given AdapterView. + +
+ Any AdaptedData returned by this method can be passed to makeDataRenderedWithinView and the + implementation should make the AdapterView bring that data item onto the screen. +
adapterView + | the AdapterView we want to interrogate the contents of. | +
---|
Iterable
of AdaptedDatas representing all data the implementation sees in
+ this viewIllegalArgumentException + | if the implementation doesn't know how to manipulate the given + adapter view. + | +
---|
Returns the data object this particular view is rendering if possible. + +
+ Implementations are expected to create a relationship between the data in the AdapterView and + the descendant views of the AdapterView that obeys the following conditions: +
+ +For example - if a PersonObject is rendered into:
+
+ LinearLayout
+ ImageView picture
+ TextView firstName
+ TextView lastName
+
+
+ + It would be expected that getDataRenderedByView(adapter, LinearLayout) would return the + PersonObject. If it were called instead with the TextView or ImageView it would return + Object.absent(). +
adapterView + | the adapterview hosting the data. | +
---|---|
descendantView + | a view which is a child, grand-child, or deeper descendant of adapterView | +
IllegalArgumentException + | if this protocol cannot interrogate this class of adapterView + | +
---|
Indicates whether or not there now exists a descendant view within adapterView that + is rendering this data.
adapterView + | the AdapterView hosting this data. | +
---|---|
adaptedData + | the data we are checking the display state for. | +
Requests that a particular piece of data held in this AdapterView is actually rendered by it. + +
+ After calling this method it expected that there will exist some descendant view of adapterView + for which calling getDataRenderedByView(adapterView, descView).get() == data.data is true. +
+ +
+ Note: this need not happen immediately. EG: an implementor handling ListView may call + listView.smoothScrollToPosition(data.opaqueToken) - which kicks off an animated scroll over + the list to the given position. The animation may be in progress after this call returns. The + only guarantee is that eventually - with no further interaction necessary - this data item + will be rendered as a child or deeper descendant of this AdapterView. +adapterView + | the adapterView hosting the data. | +
---|---|
data + | an AdaptedData instance retrieved by a prior call to getDataInAdapterView | +
IllegalArgumentException + | if this protocol cannot manipulate adapterView or if data is + not owned by this AdapterViewProtocol. + | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.AdapterViewProtocols | +
Implementations of AdapterViewProtocol
for standard SDK Widgets.
+
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Creates an implementation of AdapterViewProtocol that can work with AdapterViews that do not
+ break method contracts on AdapterView.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Creates an implementation of AdapterViewProtocol that can work with AdapterViews that do not + break method contracts on AdapterView. + +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.CloseKeyboardAction | +
Closes soft keyboard. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
android.support.test.espresso.action.CoordinatesProvider | +
+
+ ![]()
+
+
+
+
+ GeneralLocation
+
+
+
+
+ |
Interface to implement calculation of Coordinates. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Calculates coordinates of given view.
+
+
+
+
+
+ |
Calculates coordinates of given view.
view + | the View which is used for the calculation. | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.EditorAction | +
Performs whatever editor (IME) action is available on a view. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.EspressoKey.Builder | +
Builder for the EspressoKey class. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Sets the ALT_ON meta state of the resulting key.
+
+
+
+
+
+ | |||||||||||
+ On Honeycomb and above, sets the CTRL_ON meta state of the resulting key.
+
+
+
+
+
+ | |||||||||||
+ Sets the SHIFT_ON meta state of the resulting key.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Sets the ALT_ON meta state of the resulting key. +
On Honeycomb and above, sets the CTRL_ON meta state of the resulting key. On Gingerbread and + below, this is a noop. +
Sets the SHIFT_ON meta state of the resulting key. +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.EspressoKey | +
Class that wraps the key code and meta state of the desired key press. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
EspressoKey.Builder | ++ Builder for the EspressoKey class. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.GeneralClickAction | +
Enables clicking on views. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.GeneralLocation | +
Calculates coordinate position for general locations. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GeneralLocation | +BOTTOM_CENTER | ++ + + + + | +|||||||||
GeneralLocation | +BOTTOM_LEFT | ++ + + + + | +|||||||||
GeneralLocation | +BOTTOM_RIGHT | ++ + + + + | +|||||||||
GeneralLocation | +CENTER | ++ + + + + | +|||||||||
GeneralLocation | +CENTER_LEFT | ++ + + + + | +|||||||||
GeneralLocation | +CENTER_RIGHT | ++ + + + + | +|||||||||
GeneralLocation | +TOP_CENTER | ++ + + + + | +|||||||||
GeneralLocation | +TOP_LEFT | ++ + + + + | +|||||||||
GeneralLocation | +TOP_RIGHT | ++ + + + + | +|||||||||
GeneralLocation | +VISIBLE_CENTER | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.GeneralSwipeAction | +
Enables swiping across a view. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.KeyEventAction | +
Enables pressing KeyEvents on views. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.OpenLinkAction | +
Invokes onClick of a link within a TextView (made with Linkify or via another method). + Why not issue a real click event to the screen? Unfortunately, it does not seem to be possible + (at least using public APIs) to determine the location of the link on the screen. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
android.support.test.espresso.action.PrecisionDescriber | +
+
+ ![]()
+
+
+
+
+ Press
+
+
+
+
+ |
Interface to implement size of click area. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Different touch target sizes.
+
+
+
+
+
+ |
Different touch target sizes.
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.Press | +
Returns different touch target sizes. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Press | +FINGER | ++ + + + + | +|||||||||
Press | +PINPOINT | ++ + + + + | +|||||||||
Press | +THUMB | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.ReplaceTextAction | +
Replaces view text by setting EditText
s text property to given String.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.ScrollToAction | +
Enables scrolling to the given view. View must be a descendant of a ScrollView. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.Swipe | +
Executes different swipe types to given positions. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Swipe | +FAST | ++ Swipes quickly between the co-ordinates. + + + + | +|||||||||
Swipe | +SLOW | ++ Swipes deliberately slowly between the co-ordinates, to aid in visual debugging. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Swipes quickly between the co-ordinates.
Swipes deliberately slowly between the co-ordinates, to aid in visual debugging.
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.Swiper.Status | +
The result of the swipe. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Swiper.Status | +FAILURE | ++ Injecting the event was a complete failure. + + + + | +|||||||||
Swiper.Status | +SUCCESS | ++ The swipe action completed successfully. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Injecting the event was a complete failure. +
The swipe action completed successfully. +
android.support.test.espresso.action.Swiper | +
+
+ ![]()
+
+
+
+
+ Swipe
+
+
+
+
+ |
Interface to implement different swipe types. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Swiper.Status | ++ The result of the swipe. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Swipes from
+
+ startCoordinates to endCoordinates using the given
+ uiController to send MotionEvent s.
+
+
+
+ |
Swipes from startCoordinates
to endCoordinates
using the given
+ uiController
to send MotionEvent
s.
uiController + | a UiController to use to send MotionEvents to the screen. | +
---|---|
startCoordinates + | a float[] with x and y co-ordinates of the start of the swipe. | +
endCoordinates + | a float[] with x and y co-ordinates of the end of the swipe. | +
precision + | a float[] with x and y values of precision of the tap. | +
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.Tap | +
Executes different click types to given position. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Tap | +DOUBLE | ++ + + + + | +|||||||||
Tap | +LONG | ++ + + + + | +|||||||||
Tap | +SINGLE | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.action.Tapper.Status | +
The result of the tap. +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Tapper.Status | +FAILURE | ++ Injecting the event was a complete failure. + + + + | +|||||||||
Tapper.Status | +SUCCESS | ++ The Tap action completed successfully. + + + + | +|||||||||
Tapper.Status | +WARNING | ++ The action seemed to have completed - but may have been misinterpreted + by the application. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Injecting the event was a complete failure. +
The Tap action completed successfully. +
The action seemed to have completed - but may have been misinterpreted + by the application. (For Example a TAP became a LONG PRESS by measuring + its time between the down and up events). +
android.support.test.espresso.action.Tapper | +
+
+ ![]()
+
+
+
+
+ Tap
+
+
+
+
+ |
Interface to implement different click types. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Tapper.Status | ++ The result of the tap. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Sends a MotionEvent to the given UiController.
+
+
+
+
+
+ |
Sends a MotionEvent to the given UiController.
uiController + | a UiController to use to send MotionEvents to the screen. | +
---|---|
coordinates + | a float[] with x and y values of center of the tap. | +
precision + | a float[] with x and y values of precision of the tap. | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.TypeTextAction | +
Enables typing text on views. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Constructs
+
+ TypeTextAction with given string.
+
+
+
+ | |||||||||||
+ Constructs
+
+ TypeTextAction with given string.
+
+
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A mechanism for ViewActions to specify what type of views they can operate on.
+
+
+
+
+
+ | |||||||||||
+ Returns a description of the view action.
+
+
+
+
+
+ | |||||||||||
+ Performs this action on the given view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Constructs TypeTextAction
with given string. If the string is empty it results in no-op
+ (nothing is typed). By default this action sends a tap event to the center of the view to
+ attain focus before typing.
stringToBeTyped + | String To be typed by TypeTextAction
+ |
+
---|
Constructs TypeTextAction
with given string. If the string is empty it results in no-op
+ (nothing is typed).
stringToBeTyped + | String To be typed by TypeTextAction |
+
---|---|
tapToFocus + | indicates whether a tap should be sent to the underlying view before typing. + | +
A mechanism for ViewActions to specify what type of views they can operate on. + + A ViewAction can demand that the view passed to perform meets certain constraints. For example + it may want to ensure the view is already in the viewable physical screen of the device or is + of a certain type.
Matcher
that will be tested prior to calling perform.
+Returns a description of the view action. The description should not be overly long and should + fit nicely in a sentence like: "performing %description% action on view with id ..." +
Performs this action on the given view.
uiController + | the controller to use to interact with the UI. | +
---|---|
view + | the view to act upon. never null. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.action.ViewActions | +
A collection of common ViewActions
.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns an action that clears text on the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that performs a single click on the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that clicks the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that closes soft keyboard.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that double clicks the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that long clicks the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that opens a link matching the given link text and uri matchers.
+
+
+
+
+
+ | |||||||||||
+ Same as
+
+ openLink(Matcher , but uses
+ any(Uri.class) as the uriMatcher.
+
+
+
+ | |||||||||||
+ Same as
+
+ openLinkWithText(Matcher , but uses
+ is(linkText) as the linkTextMatcher.
+
+
+
+ | |||||||||||
+ Same as
+
+ openLinkWithUri(Matcher , but uses is(uri) as the
+ uriMatcher.
+
+
+
+ | |||||||||||
+ Same as
+
+ openLink(Matcher , but uses
+ any(String.class) as the linkTextMatcher.
+
+
+
+ | |||||||||||
+ Returns an action that clicks the back button.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that presses the current action button (next, done, search, etc) on the IME
+ (Input Method Editor).
+
+
+
+
+
+ | |||||||||||
+ Returns an action that presses the specified key with the specified modifiers.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that presses the key specified by the keyCode (eg.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that presses the hardware menu key.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that updates the text attribute of a view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that scrolls to the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that performs a swipe top-to-bottom across the horizontal center of the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that performs a swipe right-to-left across the vertical center of the
+ view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that performs a swipe left-to-right across the vertical center of the
+ view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that performs a swipe bottom-to-top across the horizontal center of the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that selects the view (by clicking on it) and types the provided string into
+ the view.
+
+
+
+
+
+ | |||||||||||
+ Returns an action that types the provided string into the view.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns an action that clears text on the view.
+
+ View constraints:
+
Returns an action that performs a single click on the view.
+
+ If the click takes longer than the 'long press' duration (which is possible) the provided
+ rollback action is invoked on the view and a click is attempted again.
+
+ This is only necessary if the view being clicked on has some different behaviour for long press
+ versus a normal tap.
+
+ For example - if a long press on a particular view element opens a popup menu -
+ ViewActions.pressBack() may be an acceptable rollback action.
+
+
+ View constraints:
+
Returns an action that clicks the view.
+
+ View constraints:
+
Returns an action that closes soft keyboard. If the keyboard is already closed, it is a no-op. +
Returns an action that double clicks the view.
+
+ View preconditions:
+
Returns an action that long clicks the view.
+
+
+ View preconditions:
+
Returns an action that opens a link matching the given link text and uri matchers. The action
+ is performed by invoking the link's onClick method (as opposed to actually issuing a click on
+ the screen).
+
+
+ View preconditions:
+
Same as openLink(Matcher
, but uses
+ any(Uri.class)
as the uriMatcher.
+
Same as openLinkWithText(Matcher
, but uses
+ is(linkText)
as the linkTextMatcher.
+
Same as openLinkWithUri(Matcher
, but uses is(uri)
as the
+ uriMatcher.
+
Same as openLink(Matcher
, but uses
+ any(String.class)
as the linkTextMatcher.
+
Returns an action that clicks the back button. +
Returns an action that presses the current action button (next, done, search, etc) on the IME + (Input Method Editor). The selected view will have its onEditorAction method called. +
Returns an action that presses the specified key with the specified modifiers. +
Returns an action that presses the key specified by the keyCode (eg. Keyevent.KEYCODE_BACK). +
Returns an action that presses the hardware menu key. +
Returns an action that updates the text attribute of a view.
+
+
+ View preconditions:
+
Returns an action that scrolls to the view.
+
+ View preconditions:
+
Returns an action that performs a swipe top-to-bottom across the horizontal center of the view.
+ The swipe doesn't start at the very edge of the view, but has a bit of offset.
+
+ View constraints:
+
Returns an action that performs a swipe right-to-left across the vertical center of the
+ view. The swipe doesn't start at the very edge of the view, but is a bit offset.
+
+ View constraints:
+
Returns an action that performs a swipe left-to-right across the vertical center of the
+ view. The swipe doesn't start at the very edge of the view, but is a bit offset.
+
+ View constraints:
+
Returns an action that performs a swipe bottom-to-top across the horizontal center of the view.
+ The swipe doesn't start at the very edge of the view, but has a bit of offset.
+
+ View constraints:
+
Returns an action that selects the view (by clicking on it) and types the provided string into
+ the view. Appending a \n to the end of the string translates to a ENTER key event. Note: this
+ method performs a tap on the view before typing to force the view into focus, if the view
+ already contains text this tap may place the cursor at an arbitrary position within the text.
+
+
+ View preconditions:
+
Returns an action that types the provided string into the view.
+ Appending a \n to the end of the string translates to a ENTER key event. Note: this method
+ does not change cursor position in the focused view - text is inserted at the location where
+ the cursor is currently pointed.
+
+ View preconditions:
+
AdapterViewProtocol | ++ A sadly necessary layer of indirection to interact with AdapterViews. + + + + | +
AdapterViewProtocol.DataFunction | +
+ A custom function that is applied when getData() is executed.
+
+
+
+ |
+
CoordinatesProvider | ++ Interface to implement calculation of Coordinates. + + + + | +
PrecisionDescriber | ++ Interface to implement size of click area. + + + + | +
Swiper | ++ Interface to implement different swipe types. + + + + | +
Tapper | ++ Interface to implement different click types. + + + + | +
AdapterDataLoaderAction | ++ Forces an AdapterView to ensure that the data matching a provided data matcher + is loaded into the current view hierarchy. + + + + | +
AdapterViewProtocol.AdaptedData | ++ A holder that associates a data object from an AdapterView with a token the + AdapterViewProtocol can use to force that data object to be rendered as a child or deeper + descendant of the adapter view. + + + + | +
AdapterViewProtocol.AdaptedData.Builder | ++ + + + + | +
AdapterViewProtocols | +
+ Implementations of AdapterViewProtocol for standard SDK Widgets.
+
+
+
+ |
+
CloseKeyboardAction | ++ Closes soft keyboard. + + + + | +
EditorAction | ++ Performs whatever editor (IME) action is available on a view. + + + + | +
EspressoKey | ++ Class that wraps the key code and meta state of the desired key press. + + + + | +
EspressoKey.Builder | ++ Builder for the EspressoKey class. + + + + | +
GeneralClickAction | ++ Enables clicking on views. + + + + | +
GeneralSwipeAction | ++ Enables swiping across a view. + + + + | +
KeyEventAction | ++ Enables pressing KeyEvents on views. + + + + | +
OpenLinkAction | ++ Invokes onClick of a link within a TextView (made with Linkify or via another method). + + + + | +
ReplaceTextAction | +
+ Replaces view text by setting EditText s text property to given String.
+
+
+
+ |
+
ScrollToAction | ++ Enables scrolling to the given view. + + + + | +
TypeTextAction | ++ Enables typing text on views. + + + + | +
ViewActions | +
+ A collection of common ViewActions .
+
+
+
+ |
+
GeneralLocation | ++ Calculates coordinate position for general locations. + + + + | +
Press | ++ Returns different touch target sizes. + + + + | +
Swipe | ++ Executes different swipe types to given positions. + + + + | +
Swiper.Status | ++ The result of the swipe. + + + + | +
Tap | ++ Executes different click types to given position. + + + + | +
Tapper.Status | ++ The result of the tap. + + + + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.assertion.LayoutAssertions | +
A collection of layout ViewAssertion
s.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a
+
+ ViewAssertion that asserts that view hierarchy does not contain
+ ellipsized or cut off text views.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view hierarchy does not contain
+ multiline buttons.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that descendant views matching the selector
+ do not overlap each other.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that descendant objects assignable
+ to TextView or ImageView do not overlap each other.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a ViewAssertion
that asserts that view hierarchy does not contain
+ ellipsized or cut off text views.
+
Returns a ViewAssertion
that asserts that view hierarchy does not contain
+ multiline buttons.
+
Returns a ViewAssertion
that asserts that descendant views matching the selector
+ do not overlap each other.
+
+ Example: onView(rootView).check(noOverlaps(isAssignableFrom(TextView.class)); +
Returns a ViewAssertion
that asserts that descendant objects assignable
+ to TextView or ImageView do not overlap each other.
+
+ Example: onView(rootView).check(noOverlaps()) +
java.lang.Object | +|
↳ | + +android.support.test.espresso.assertion.PositionAssertions | +
A collection of ViewAssertion
s for checking relative position of elements on the screen.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns an Assertion that asserts that view displayed is completely above
+ the view matching the given matcher.
+
+
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely
+ below the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely
+ aligned to bottom with the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely aligned
+ to the left as the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely left of
+ the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely aligned
+ to the right as the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely right of
+ the view matching the given matcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAssertion that asserts that view displayed is completely
+ aligned to top with the view matching the given matcher.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns an Assertion that asserts that view displayed is completely above + the view matching the given matcher.
+ | if there is more than 1 pixel of vertical overlap. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely
+ below the view matching the given matcher.
+ | if there is more than 1 pixel of vertical overlap. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely
+ aligned to bottom with the view matching the given matcher.
+
+
The bottom 'y' coordinate of the view displayed must equal the bottom 'y' + coordinate of the view matching the given matcher.
+ | if the views are not aligned bottom. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely aligned
+ to the left as the view matching the given matcher.
+
+
The left 'x' coordinate of the view displayed must equal the left 'x' + coordinate of the view matching the given matcher.
+ | if the views are not aligned to the left. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely left of
+ the view matching the given matcher.
+ | if there is more than 1 pixel of horizontal overlap. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely aligned
+ to the right as the view matching the given matcher.
+
+
The right 'x' coordinate of the view displayed must equal the right 'x' + coordinate of the view matching the given matcher.
+ | if the views are not aligned to the right. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely right of
+ the view matching the given matcher.
+ | if there is more than 1 pixel of horizontal overlap. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
Returns a ViewAssertion
that asserts that view displayed is completely
+ aligned to top with the view matching the given matcher.
+
+
The top 'y' coordinate of the view displayed must equal the top 'y' + coordinate of the view matching the given matcher.
+ | if the views are not aligned top. | +
---|---|
AmbiguousViewMatcherException + | if more than one view matches the given matcher. | +
NoMatchingViewException + | if no views match the given matcher. + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.assertion.ViewAssertions | +
A collection of common ViewAssertion
s.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns an assert that ensures the view matcher does not find any matching view in the
+ hierarchy.
+
+
+
+
+
+ | |||||||||||
+ Returns a generic
+
+ ViewAssertion that asserts that a view exists in the view hierarchy
+ and is matched by the given view matcher.
+
+
+
+ | |||||||||||
+ Returns a generic
+
+ ViewAssertion that asserts that the descendant views selected by the
+ selector match the specified matcher.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns an assert that ensures the view matcher does not find any matching view in the + hierarchy. +
Returns a generic ViewAssertion
that asserts that a view exists in the view hierarchy
+ and is matched by the given view matcher.
+
Returns a generic ViewAssertion
that asserts that the descendant views selected by the
+ selector match the specified matcher.
+
+ Example: onView(rootView).check(selectedDescendantsMatch(
+ not(isAssignableFrom(TextView.class)), hasContentDescription()));
+
LayoutAssertions | +
+ A collection of layout ViewAssertion s.
+
+
+
+ |
+
PositionAssertions | +
+ A collection of ViewAssertion s for checking relative position of elements on the screen.
+
+
+
+ |
+
ViewAssertions | +
+ A collection of common ViewAssertion s.
+
+
+
+ |
+
android.support.test.espresso.base.ActiveRootLister | +
Provides access to all root views in an application. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Lists the active roots in an application at this moment.
+
+
+
+
+
+ |
Lists the active roots in an application at this moment.
IllegalStateException + | if invoked from a thread besides the main thread. + | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.BaseLayerModule.FailureHandlerHolder | +
Holder for AtomicReference
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.BaseLayerModule | +
Dagger module for creating the implementation classes within the base package. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
BaseLayerModule.FailureHandlerHolder | +
+ Holder for AtomicReference |
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
android.support.test.espresso.base.Default | +
Annotates a default provider. +
+ + + + + +
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.DefaultFailureHandler | +
Espresso's default FailureHandler
. If this does not fit your needs, feel free to provide
+ your own implementation via Espresso.setFailureHandler(FailureHandler).
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Handle the given error in a manner that makes sense to the environment in which the test is
+ executed (e.g.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Handle the given error in a manner that makes sense to the environment in which the test is + executed (e.g. take a screenshot, output extra debug info, etc). Upon handling, most handlers + will choose to propagate the error. +
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.IdlingResourceRegistry | +
Keeps track of user-registered IdlingResource
s.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a list of all currently registered
+
+ IdlingResource s.
+
+
+
+ | |||||||||||
+ Registers the given resources.
+
+
+
+
+
+ | |||||||||||
+ Unregisters the given resources.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a list of all currently registered IdlingResource
s.
+ This method is safe to call from any thread.
IdlingResource
s.
+Registers the given resources. If any of the given resources are already + registered, a warning is logged.
Unregisters the given resources. If any of the given resources are not already + registered, a warning is logged.
android.support.test.espresso.base.MainThread | +
Annotates an Executor that executes tasks on the main thread +
+ + + + + +
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.RootViewPicker | +
Provides the root View of the top-most Window, with which the user can interact. View is + guaranteed to be in a stable state - i.e. not pending any updates from the application. + + This provider can only be accessed from the main thread. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.base.ViewFinderImpl | +
Implementation of ViewFinder
.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Immediately locates a single view within the provided view hierarchy.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Immediately locates a single view within the provided view hierarchy. + + If multiple views match, or if no views match the appropriate exception is thrown.
AmbiguousViewMatcherException + | + |
---|---|
NoMatchingViewException + | + |
Default | ++ Annotates a default provider. + + + + | +
MainThread | ++ Annotates an Executor that executes tasks on the main thread + + + + + | +
ActiveRootLister | ++ Provides access to all root views in an application. + + + + | +
BaseLayerModule | ++ Dagger module for creating the implementation classes within the base package. + + + + | +
BaseLayerModule.FailureHandlerHolder | +
+ Holder for AtomicReference |
+
DefaultFailureHandler | +
+ Espresso's default FailureHandler .
+
+
+
+ |
+
IdlingResourceRegistry | +
+ Keeps track of user-registered IdlingResource s.
+
+
+
+ |
+
RootViewPicker | ++ Provides the root View of the top-most Window, with which the user can interact. + + + + | +
ViewFinderImpl | +
+ Implementation of ViewFinder .
+
+
+
+ |
+
java.lang.Object | +|
↳ | + +android.support.test.espresso.contrib.CountingIdlingResource | +
An implementation of IdlingResource
that determines idleness by maintaining an internal
+ counter. When the counter is 0 - it is considered to be idle, when it is non-zero it is not
+ idle. This is very similar to the way a Semaphore
behaves.
+
+ The counter may be incremented or decremented from any thread. If it reaches an illogical state + (like counter less than zero) it will throw an IllegalStateException. +
++ This class can then be used to wrap up operations that while in progress should block tests from + accessing the UI. +
+ +
+ public interface FooServer {
+ public Foo newFoo();
+ public void updateFoo(Foo foo);
+
+
+ public DecoratedFooServer implements FooServer {
+ private final FooServer realFooServer;
+ private final CountingIdlingResource fooServerIdlingResource;
+
+ public DecoratedFooServer(FooServer realFooServer,
+ CountingIdlingResource fooServerIdlingResource) {
+ this.realFooServer = checkNotNull(realFooServer);
+ this.fooServerIdlingResource = checkNotNull(fooServerIdlingResource);
+ }
+
+ public Foo newFoo() {
+ fooServerIdlingResource.increment();
+ try {
+ return realFooServer.newFoo();
+ } finally {
+ fooServerIdlingResource.decrement();
+ }
+ }
+
+ public void updateFoo(Foo foo) {
+ fooServerIdlingResource.increment();
+ try {
+ realFooServer.updateFoo(foo);
+ } finally {
+ fooServerIdlingResource.decrement();
+ }
+ }
+ }
+ }
+
+
+ Then in your test setup:
+
+ public void setUp() throws Exception {
+ super.setUp();
+ FooServer realServer = FooApplication.getFooServer();
+ CountingIdlingResource countingResource = new CountingIdlingResource("FooServerCalls");
+ FooApplication.setFooServer(new DecoratedFooServer(realServer, countingResource));
+ Espresso.registerIdlingResource(countingResource);
+
+ }
+
+
+
+
+
+
+
+
+Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Creates a CountingIdlingResource without debug tracing.
+
+
+
+
+
+ | |||||||||||
+ Creates a CountingIdlingResource.
+
+
+
+
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Decrements the count of in-flight transactions to the resource being monitored.
+
+
+
+
+
+ | |||||||||||
+ Prints the current state of this resource to the logcat at info level.
+
+
+
+
+
+ | |||||||||||
+ Returns the name of the resources (used for logging and idempotency of registration).
+
+
+
+
+
+ | |||||||||||
+ Increments the count of in-flight transactions to the resource being monitored.
+
+
+
+
+
+ | |||||||||||
+ Returns
+
+ true if resource is currently idle.
+
+
+
+ | |||||||||||
+ Registers the given
+
+ IdlingResource.ResourceCallback with the resource.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Creates a CountingIdlingResource without debug tracing.
resourceName + | the resource name this resource should report to Espresso. + | +
---|
Creates a CountingIdlingResource.
resourceName + | the resource name this resource should report to Espresso. | +
---|---|
debugCounting + | if true increment & decrement calls will print trace information to logs. + | +
Decrements the count of in-flight transactions to the resource being monitored. + + If this operation results in the counter falling below 0 - an exception is raised.
IllegalStateException + | if the counter is below 0. + | +
---|
Prints the current state of this resource to the logcat at info level. +
Returns the name of the resources (used for logging and idempotency of registration). +
Increments the count of in-flight transactions to the resource being monitored. + + This method can be called from any thread. +
Returns true
if resource is currently idle. Espresso will always call this
+ method from the main thread, therefore it should be non-blocking and return immediately.
+
Registers the given IdlingResource.ResourceCallback
with the resource. Espresso will call this method:
+
IdlingResource.ResourceCallback
so it can be notified asynchronously
+ that your resource is idle
+ java.lang.Object | +|
↳ | + +android.support.test.espresso.contrib.DrawerActions | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Closes the
+
+ DrawerLayout with the given id.
+
+
+
+ | |||||||||||
+ Opens the
+
+ DrawerLayout with the given id.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Closes the DrawerLayout
with the given id. This method blocks until the drawer is fully
+ closed. No operation if the drawer is already closed.
+
Opens the DrawerLayout
with the given id. This method blocks until the drawer is fully
+ open. No operation if the drawer is already open.
+
java.lang.Object | +|
↳ | + +android.support.test.espresso.contrib.DrawerMatchers | +
Hamcrest matchers for a DrawerLayout
.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a matcher that verifies that the drawer is closed.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that verifies that the drawer is open.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a matcher that verifies that the drawer is closed. Matches only when the drawer is
+ fully closed. Use isOpen()
instead of not(isClosed()))
when you wish to check
+ that the drawer is fully open.
+
Returns a matcher that verifies that the drawer is open. Matches only when the drawer is fully
+ open. Use isClosed()
instead of not(isOpen())
when you wish to check that the
+ drawer is fully closed.
+
java.lang.Object | +|
↳ | + +android.support.test.espresso.contrib.PickerActions | +
Espresso action for interacting with DatePicker
and
+ TimePicker
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a
+
+ ViewAction that sets a date on a DatePicker .
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAction that sets a time on a TimePicker .
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a ViewAction
that sets a date on a DatePicker
.
+
Returns a ViewAction
that sets a time on a TimePicker
.
+
android.support.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction | +
Most RecyclerViewActions are given a matcher to select a particular view / viewholder within + the RecyclerView. In this case the default behaviour is to expect that the matcher matches 1 + and only one item within the RecyclerView. + + This interface gives users the ability to override that type of behaviour and explicitly + select an item in the RecyclerView at a given position. This is similar to on the + onData(...).atPosition() api for AdapterViews. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a new ViewAction which will cause the ViewAction to operate upon the position-th
+ element which the matcher has selected.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a new ViewAction which will cause the ViewAction to operate upon the position-th + element which the matcher has selected.
position + | a 0-based index into the list of matching elements within the RecyclerView. | +
---|
IllegalArgumentException + | if position < 0. + | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.contrib.RecyclerViewActions | +
ViewAction
s to interact RecyclerView
. RecyclerView works differently than
+ AdapterView
. In fact, RecyclerView is not an AdapterView anymore, hence it can't be used
+ in combination with onData(Matcher)
.
+
+
+ To use ViewAction
s in this class use onView(Matcher)
with a
+
+ Matcher
that matches your RecyclerView
, then perform a
+ ViewAction
from this class.
+
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RecyclerViewActions.PositionableRecyclerViewAction | ++ Most RecyclerViewActions are given a matcher to select a particular view / viewholder within + the RecyclerView. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Performs a
+
+ ViewAction on a view matched by viewHolderMatcher.
+
+
+
+ | |||||||||||
+ Performs a
+
+ ViewAction on a view matched by viewHolderMatcher.
+
+
+
+ | |||||||||||
+ Performs a
+
+ ViewAction on a view at position.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAction which scrolls RecyclerView to the view matched by
+ itemViewMatcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAction which scrolls RecyclerView to the view matched by
+ viewHolderMatcher.
+
+
+
+ | |||||||||||
+ Returns a
+
+ ViewAction which scrolls RecyclerView to a position.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Performs a ViewAction
on a view matched by viewHolderMatcher.
+
+
viewHolderMatcher + | a
+ Matcher that matchesan item view holder in RecyclerView |
+
---|---|
viewAction + | the action that is performed on the view matched by viewHolderMatcher | +
PerformException + | if there are more than one items matching given viewHolderMatcher. + | +
---|
Performs a ViewAction
on a view matched by viewHolderMatcher.
+
+
itemViewMatcher + | a
+ Matcher that matches an item view in RecyclerView |
+
---|---|
viewAction + | the action that is performed on the view matched by viewHolderMatcher | +
PerformException + | if there are more than one items matching given viewHolderMatcher. + | +
---|
Performs a ViewAction
on a view at position.
+
+
position + | position of a view in RecyclerView |
+
---|---|
viewAction + | the action that is performed on the view matched by itemViewMatcher + | +
Returns a ViewAction
which scrolls RecyclerView
to the view matched by
+ itemViewMatcher.
+
+
+ This approach uses RecyclerView.ViewHolder
s to find the target view. It will create one ViewHolder
+ per item type and bind adapter data to the ViewHolder. If the itemViewMatcher matches a
+ ViewHolder the current position of the View is used to perform a
+ scrollToPosition(int)
.
+
itemViewMatcher + | a
+ Matcher that matches an item view in RecyclerView |
+
---|
PerformException + | if there are more than one items matching given viewHolderMatcher. + | +
---|
Returns a ViewAction
which scrolls RecyclerView
to the view matched by
+ viewHolderMatcher.
+
+
+ This approach uses RecyclerView.ViewHolder
s to find the target view. It will create one ViewHolder
+ per item type and bind adapter data to the ViewHolder. If the itemViewMatcher matches a
+ ViewHolder the current position of the View is used to perform a
+ scrollToPosition(int)
. Note: scrollTo method is not overloaded, method
+ overloading with generic parameters is not possible.
+
viewHolderMatcher + | a Matcher that matches an item view holder in
+ RecyclerView |
+
---|
PerformException + | if there are more than one items matching given viewHolderMatcher. + | +
---|
Returns a ViewAction
which scrolls RecyclerView
to a position.
position + | the position of the view to scroll to + | +
---|
RecyclerViewActions.PositionableRecyclerViewAction | ++ Most RecyclerViewActions are given a matcher to select a particular view / viewholder within + the RecyclerView. + + + + | +
CountingIdlingResource | +
+ An implementation of IdlingResource that determines idleness by maintaining an internal
+ counter.
+
+
+
+ |
+
DrawerActions | +
+ Espresso actions for using a DrawerLayout .
+
+
+
+ |
+
DrawerMatchers | +
+ Hamcrest matchers for a DrawerLayout .
+
+
+
+ |
+
PickerActions | +
+ Espresso action for interacting with DatePicker and
+ TimePicker .
+
+
+
+ |
+
RecyclerViewActions | +
+ ViewAction s to interact RecyclerView .
+
+
+
+ |
+
java.lang.Object | +||
↳ | + +org.hamcrest.BaseMatcher<T> | +|
+ + | ↳ | + +android.support.test.espresso.matcher.BoundedMatcher<T, S extends T> | +
Some matcher sugar that lets you create a matcher for a given type + but only process items of a specific subtype of that matcher.
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.matcher.CursorMatchers | +
A collection of Hamcrest matchers that matches a data row in a Cursor
.
+
+
+ AdapterView
s that are backed by a Cursor
are very common. This class contains
+
+ Matcher
s that can be used together with
+ onData(Matcher)
to match a data row in a
+ Cursor
.
+ The
+ Matcher
s can only operate on a single data row of the cursor and Espresso
+ internally moves the Cursor
to the correct adapter position.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.matcher.LayoutMatchers | +
A collection of hamcrest matches to detect typical layout issues. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Matches TextView elements having ellipsized text.
+
+
+
+
+
+ | |||||||||||
+ Matches TextView elements having multiline text.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Matches TextView elements having ellipsized text. If text is too long to fit into a TextView, + it can be either ellipsized ('Too long' shown as 'Too l…' or '… long') or cut off ('Too + long' shown as 'Too l'). Though acceptable in some cases, usually indicates bad user + experience. +
Matches TextView elements having multiline text. +
java.lang.Object | +|
↳ | + +android.support.test.espresso.matcher.PreferenceMatchers | +
A collection of hamcrest matchers that match Preference
s.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.matcher.RootMatchers | +
A collection of matchers for Root
objects.
+
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DEFAULT | +
+ Espresso's default Root matcher.
+
+
+
+ |
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Matches
+
+ Root s that are dialogs (i.e.
+
+
+
+ | |||||||||||
+ Matches
+
+ Root s that can take window focus.
+
+
+
+ | |||||||||||
+ Matches
+
+ Root s that are popups - like autocomplete suggestions or the actionbar spinner.
+
+
+
+ | |||||||||||
+ Matches
+
+ Root s that can receive touch events.
+
+
+
+ | |||||||||||
+ Matches
+
+ Root s with decor views that match the given view matcher.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Espresso's default Root
matcher.
+
Matches Root
s that are dialogs (i.e. is not a window of the currently resumed
+ activity).
+
Matches Root
s that can take window focus.
+
Matches Root
s that are popups - like autocomplete suggestions or the actionbar spinner.
+
Matches Root
s that can receive touch events.
+
Matches Root
s with decor views that match the given view matcher.
+
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.espresso.matcher.ViewMatchers.Visibility | +
Enumerates the possible list of values for View.getVisibility(). +
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ViewMatchers.Visibility | +GONE | ++ + + + + | +|||||||||
ViewMatchers.Visibility | +INVISIBLE | ++ + + + + | +|||||||||
ViewMatchers.Visibility | +VISIBLE | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.matcher.ViewMatchers | +
A collection of hamcrest matchers that match View
s.
+
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ViewMatchers.Visibility | ++ Enumerates the possible list of values for View.getVisibility(). + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ A replacement for MatcherAssert.assertThat that renders View objects nicely.
+
+
+
+
+
+ | |||||||||||
+ A replacement for MatcherAssert.assertThat that renders View objects nicely.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s based on the presence of a descendant in its
+ view hierarchy.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s currently have focus.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches views that support input methods (e.g.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches views that support input methods (e.g.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ TextView s that have links.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches Views which are an instance of or subclass of the provided
+ class.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
+ and is in checked state.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that are clickable.
+
+
+
+ | |||||||||||
+ Returns a matcher which only accepts a view whose height and width fit perfectly within
+ the currently displayed region of this view.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s based on the given ancestor type.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that are currently displayed on the screen to
+ the user.
+
+
+
+ | |||||||||||
+ Returns a matcher which accepts a view so long as a given percentage of that view's area is
+ not obscured by any other view and is thus visible to the user.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that are enabled.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that are focusable.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ WebView if they are evaluating Javascript.
+
+
+
+ | |||||||||||
+ Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
+ and is not in checked state.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches root
+
+ View .
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that are selected.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches views that support input methods.
+
+
+
+
+
+ | |||||||||||
+ A matcher that returns true if and only if the view's child is accepted by the provided
+ matcher.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches Views with class name matching the given matcher.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s that have "effective" visibility set to the
+ given value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches a descendant of
+
+ TextView that is displaying the hint
+ associated with the given resource id.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ TextView s based on hint property value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ TextView based on it's hint property value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s based on resource ids.
+
+
+
+ | |||||||||||
+ Same as withId(is(int)), but attempts to look up resource name of the given id and use an
+ R.id.myView style description with describeTo.
+
+
+
+
+
+ | |||||||||||
+ A matcher that accepts a view if and only if the view's parent is accepted by the provided
+ matcher.
+
+
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ Spinner based on it's selected item's toString value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches a descendant of
+
+ Spinner that is displaying the string
+ of the selected item associated with the given resource id.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ Spinner s based on toString value of the selected item.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s based on tag keys.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View based on tag keys.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ View s based on tag property values.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ TextView based on its text property value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches
+
+ TextView s based on text property value.
+
+
+
+ | |||||||||||
+ Returns a matcher that matches a descendant of
+
+ TextView that is displaying the string
+ associated with the given resource id.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
A replacement for MatcherAssert.assertThat that renders View objects nicely.
message + | the message to display. | +
---|---|
actual + | the actual value. | +
matcher + | a matcher that accepts or rejects actual. + | +
A replacement for MatcherAssert.assertThat that renders View objects nicely.
actual + | the actual value. | +
---|---|
matcher + | a matcher that accepts or rejects actual. + | +
Returns a matcher that matches View
s based on the presence of a descendant in its
+ view hierarchy.
descendantMatcher + | the type of the descendant to match on + | +
---|
Returns a matcher that matches View
s currently have focus.
+
Returns a matcher that matches views that support input methods (e.g. EditText) and have the
+ specified IME action set in its EditorInfo
.
imeAction + | the IME action to match + | +
---|
Returns a matcher that matches views that support input methods (e.g. EditText) and have the
+ specified IME action set in its EditorInfo
.
imeActionMatcher + | a matcher for the IME action + | +
---|
Returns a matcher that matches TextView
s that have links.
+
Returns an
+ Matcher
that matches View
s based on their siblings.
+
+ This may be particularly useful when a view cannot be uniquely selected on properties such as
+ text or R.id. For example: a call button is repeated several times in a contacts layout
+ and the only way to differentiate the call button view is by what appears next to it (e.g.
+ the unique name of the contact).
siblingMatcher + | a
+ Matcher for the sibling of the view.
+ |
+
---|
Returns a matcher that matches Views which are an instance of or subclass of the provided + class. Some versions of Hamcrest make the generic typing of this a nightmare, so we have a + special case for our users. +
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) + and is in checked state. +
Returns a matcher that matches View
s that are clickable.
+
Returns a matcher which only accepts a view whose height and width fit perfectly within + the currently displayed region of this view. +
+ There exist views (such as ScrollViews) whose height and width are larger then the physical + device screen by design. Such views will _never_ be completely displayed. +Returns a matcher that matches View
s based on the given ancestor type.
ancestorMatcher + | the type of the ancestor to match on + | +
---|
Returns a matcher that matches View
s that are currently displayed on the screen to
+ the user.
+
Returns a matcher which accepts a view so long as a given percentage of that view's area is + not obscured by any other view and is thus visible to the user.
areaPercentage + | an integer ranging from (0, 100] indicating how much percent of the + surface area of the view must be shown to the user to be accepted. + | +
---|
Returns a matcher that matches View
s that are enabled.
+
Returns a matcher that matches View
s that are focusable.
+
Returns a matcher that matches WebView
if they are evaluating Javascript.
+
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) + and is not in checked state. +
Returns a matcher that matches root View
.
+
Returns a matcher that matches View
s that are selected.
+
Returns a matcher that matches views that support input methods. +
A matcher that returns true if and only if the view's child is accepted by the provided + matcher.
childMatcher + | the matcher to apply on the child views. + | +
---|
Returns a matcher that matches Views with class name matching the given matcher. +
charSequenceMatcher + | a CharSequence
+ Matcher for the content description
+ |
+
---|
Returns a matcher that matches View
s that have "effective" visibility set to the
+ given value. Effective visibility takes into account not only the view's visibility value,
+ but also that of its ancestors. In case of View.VISIBLE, this means that the view and all of
+ its ancestors have visibility=VISIBLE. In case of GONE and INVISIBLE, it's the opposite -
+ any GONE or INVISIBLE parent will make all of its children have their effective visibility.
+
Returns a matcher that matches a descendant of TextView
that is displaying the hint
+ associated with the given resource id.
resourceId + | the string resource the text view is expected to have as a hint. + | +
---|
Returns a matcher that matches TextView
based on it's hint property value. Note:
+ View's Sugar for withHint(is("string")).
Returns a matcher that matches View
s based on resource ids. Note: Android resource
+ ids are not guaranteed to be unique. You may have to pair this matcher with another one to
+ guarantee a unique view selection.
integerMatcher + | a Matcher for resource ids + | +
---|
Same as withId(is(int)), but attempts to look up resource name of the given id and use an + R.id.myView style description with describeTo. If resource lookup is unavailable, at the time + describeTo is invoked, this will print out a simple "with id: %d". If resource lookup is + available, but looking up the name for the given id, fails, "with id: %d (resource name not + found)" will be returned as the description.
id + | the resource id. + | +
---|
A matcher that accepts a view if and only if the view's parent is accepted by the provided + matcher.
parentMatcher + | the matcher to apply on getParent. + | +
---|
Returns a matcher that matches Spinner
based on it's selected item's toString value.
+
Returns a matcher that matches a descendant of Spinner
that is displaying the string
+ of the selected item associated with the given resource id.
resourceId + | the string resource the text view is expected to hold. + | +
---|
Returns a matcher that matches View
s based on tag keys.
key + | to match | +
---|---|
objectMatcher + | Object to match + | +
Returns a matcher that matches View
based on tag keys.
key + | to match + | +
---|
Returns a matcher that matches View
s based on tag property values.
tagValueMatcher + | a Matcher for the view's tag property value + | +
---|
Returns a matcher that matches TextView
based on its text property value. Note:
+ View's Sugar for withText(is("string")).
Returns a matcher that matches a descendant of TextView
that is displaying the string
+ associated with the given resource id.
resourceId + | the string resource the text view is expected to hold. + | +
---|
BoundedMatcher<T, S extends T> | ++ Some matcher sugar that lets you create a matcher for a given type + but only process items of a specific subtype of that matcher. + + + + | +
CursorMatchers | +
+ A collection of Hamcrest matchers that matches a data row in a Cursor .
+
+
+
+ |
+
LayoutMatchers | ++ A collection of hamcrest matches to detect typical layout issues. + + + + | +
PreferenceMatchers | +
+ A collection of hamcrest matchers that match Preference s.
+
+
+
+ |
+
RootMatchers | +
+ A collection of matchers for Root objects.
+
+
+
+ |
+
ViewMatchers | +
+ A collection of hamcrest matchers that match View s.
+
+
+
+ |
+
ViewMatchers.Visibility | ++ Enumerates the possible list of values for View.getVisibility(). + + + + | +
EspressoException | +
+ Used for identifying an exception as coming from the Espresso framework.
+
+
+
+ |
+
FailureHandler | ++ Handles failures that happen during test execution. + + + + | +
IdlingResource | ++ Represents a resource of an application under test which can cause asynchronous background work + to happen during test execution (e.g. + + + + | +
IdlingResource.ResourceCallback | +
+ Registered by an IdlingResource to notify Espresso of a transition to idle.
+
+
+
+ |
+
UiController | +
+ Provides base-level UI operations (such as injection of MotionEvent s) that can be used to
+ build user actions such as clicks, scrolls, swipes, etc.
+
+
+
+ |
+
ViewAction | ++ Responsible for performing an interaction on the given View element. + + + + | +
ViewAssertion | ++ Responsible for performing assertions on a View element. + + + + | +
ViewFinder | ++ Uses matchers to locate particular views within the view hierarchy. + + + + | +
AmbiguousViewMatcherException.Builder | +
+ Builder for AmbiguousViewMatcherException .
+
+
+
+ |
+
DataInteraction | ++ An interface to interact with data displayed in AdapterViews. + + + + | +
Espresso | ++ Entry point to the Espresso framework. + + + + | +
GraphHolder | ++ Holds Espresso's ObjectGraph. + + + + | +
IdlingPolicies | ++ Allows users fine grain control over idling policies. + + + + | +
IdlingPolicy | ++ Allows users to control idling idleTimeouts in Espresso. + + + + | +
NoMatchingViewException.Builder | +
+ Builder for NoMatchingViewException .
+
+
+
+ |
+
PerformException.Builder | +
+ Builder for PerformException .
+
+
+
+ |
+
Root | ++ Represents a root view in the application and optionally the layout params of the window holding + it. + + + + | +
Root.Builder | ++ + + + + | +
ViewInteraction | ++ Provides the primary interface for test authors to perform actions or asserts on views. + + + + | +
AmbiguousViewMatcherException | +
+ An exception which indicates that a Matcher |
+
AppNotIdleException | ++ An exception which indicates that the App has not become idle even after the specified duration. + + + + | +
IdlingResourceTimeoutException | +
+ Indicates that an IdlingResource , which has been registered with the framework, has not
+ idled within the allowed time.
+
+
+
+ |
+
InjectEventSecurityException | +
+ An checked Exception indicating that event injection failed with a
+ SecurityException .
+
+
+
+ |
+
NoActivityResumedException | ++ An exception which indicates that there are no activities in stage RESUMED. + + + + | +
NoMatchingRootException | +
+ Indicates that a given matcher did not match any Root s (windows) from those that are
+ currently available.
+
+
+
+ |
+
NoMatchingViewException | ++ Indicates that a given matcher did not match any elements in the view hierarchy. + + + + | +
PerformException | ++ Indicates that an exception occurred while performing a ViewAction on the UI thread. + + + + | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.util.ActivityLifecycles | +
Helper methods to understand ActivityLifecycle of the app. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Indicates whether or not an Activity in our app is currently in the foreground.
+
+
+
+
+
+ | |||||||||||
+ Indicates whether or not an Activity exists in our app within the "Visible Lifetime" state.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Indicates whether or not an Activity in our app is currently in the foreground. + +
The "Foreground lifetime" of an activity occurs after a call to onResume and before a call + to onPause. + +
During this time, the activity is in front of all other activities and is currently + receiving user input.
monitor + | the ActivityLifecycleMonitor to use. | +
---|
Indicates whether or not an Activity exists in our app within the "Visible Lifetime" state. + +
The "Visible Lifetime" is defined as an activity who's onStart() method has been called but + who's onStop() method has not been called. + +
During this time, the Activity may be visible to the user, and it may be receiving input + from the user. This time is a superset of the "Foreground lifetime' of the activity. + +
It may be the case that an application has activities in the "visible lifetime" but none in + the "Foreground lifetime." It may be the case that without user input an activity will shortly + transition into the "Foreground lifetime" in this state, however it also may not transition + without further user interaction.
monitor + | the ActivityLifecycleMonitor to use | +
---|
java.lang.Object | +|
↳ | + +android.support.test.espresso.util.HumanReadables | +
Text converters for various Android objects. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Transforms an arbitrary view into a string with (hopefully) enough debug info.
+
+
+
+
+
+ | |||||||||||
+ Prints out an error message feature the view hierarchy starting at the rootView.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Transforms an arbitrary view into a string with (hopefully) enough debug info.
v + | nullable view | +
---|
Prints out an error message feature the view hierarchy starting at the rootView.
rootView + | the root of the hierarchy tree to print out. | +
---|---|
problemViews + | list of the views that you would like to point out are causing the error + message or null, if you want to skip this feature. | +
errorHeader + | the header of the error message (should contain the description of why the + error is happening). | +
problemViewSuffix + | the message to append to the view description in the tree printout. + Required if problemViews is supplied. Otherwise, null is acceptable. | +
java.lang.Object | +|
↳ | + +android.support.test.espresso.util.TreeIterables.ViewAndDistance | +
Represents the distance a given view is from the root view. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|
↳ | + +android.support.test.espresso.util.TreeIterables | +
Utility methods for iterating over tree structured items. + + Since the view hierarchy is a tree - having a method of iterating over its contents + is useful. + + This is generalized for any object which can display tree like qualities - but this + generalization was done for testability concerns (since creating View hierarchies is a pain). + + Only public methods of this utility class are considered public API of the test framework. +
+ + + + + +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TreeIterables.ViewAndDistance | ++ Represents the distance a given view is from the root view. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns an iterable which iterates thru the provided view and its children in a
+ breadth-first, row-level-order traversal.
+
+
+
+
+
+ | |||||||||||
+ Returns an iterable which iterates thru the provided view and its children in a
+ depth-first, in-order traversal.
+
+
+
+
+
+ | |||||||||||
+ Creates an iterable that traverses the tree formed by the given root.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns an iterable which iterates thru the provided view and its children in a + breadth-first, row-level-order traversal. That is to say that for a view such as: + Root + / | \ + A R U + /| |\ + B D G N + Will be iterated: Root, A, R, U, B, D, G, N
root + | the non-null, root view. + | +
---|
Returns an iterable which iterates thru the provided view and its children in a + depth-first, in-order traversal. That is to say that for a view such as: + Root + / | \ + A R U + /| |\ + B D G N + Will be iterated: Root, A, B, D, R, G, N, U.
root + | the non-null, root view. + | +
---|
Creates an iterable that traverses the tree formed by the given root. + + Along with iteration order, the distance from the root element is also tracked.
root + | the root view to track from. | +
---|
ActivityLifecycles | ++ Helper methods to understand ActivityLifecycle of the app. + + + + | +
HumanReadables | ++ Text converters for various Android objects. + + + + | +
TreeIterables | ++ Utility methods for iterating over tree structured items. + + + + | +
TreeIterables.ViewAndDistance | ++ Represents the distance a given view is from the root view. + + + + | +
android.support.test.filters.FlakyTest | +
Designates a test as being flaky (non-deterministic). +
+ Can then be used to filter tests on execution using -e annotation or -e notAnnotation as + desired. + + + + + + +
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
android.support.test.filters.RequiresDevice | +
Indicates that a specific test should not be run on emulator. +
+ It will be executed only if the test is running on the physical android device. + + + + + + +
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
android.support.test.filters.SdkSuppress | +
Indicates that a specific test or class requires a minimum API Level to execute. +
+ Test(s) will be skipped when executed on android platforms less than specified level. + + + + + + +
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
FlakyTest | ++ Designates a test as being flaky (non-deterministic). + + + + | +
RequiresDevice | ++ Indicates that a specific test should not be run on emulator. + + + + | +
SdkSuppress | ++ Indicates that a specific test or class requires a minimum API Level to execute. + + + + | +
InstrumentationRegistry | ++ An exposed registry instance that holds a reference to the instrumentation running in the + process and it's arguments. + + + + | +
java.lang.Object | +||||
↳ | + +org.junit.runner.Runner | +|||
+ + | ↳ | + +org.junit.runners.ParentRunner<T> | +||
+ + | + + | ↳ | + +org.junit.runners.BlockJUnit4ClassRunner | +|
+ + | + + | + + | ↳ | + +android.support.test.runner.AndroidJUnit4 | +
Aliases the current default Android JUnit 4 class runner, for future-proofing. If
+ future versions of JUnit change the default Runner class, they will also
+ change the definition of this class. Developers wanting to explicitly tag a
+ class as an Android JUnit 4 class should use @RunWith(AndroidJUnit4.class)
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Constructs a new instance of the default runner
+
+
+
+
+
+
+ |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Default to
+
+
+ Test level timeout if set.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Constructs a new instance of the default runner +
InitializationError + | + |
---|
Default to
+ Test
level timeout if set. Otherwise, set the timeout that was passed to the
+ instrumentation via argument
+
java.lang.Object | +|||
↳ | + +android.app.Instrumentation | +||
+ + | ↳ | + +android.support.test.runner.MonitoringInstrumentation | +|
+ + | + + | ↳ | + +android.support.test.runner.AndroidJUnitRunner | +
An Instrumentation
that runs JUnit3 and JUnit4 tests against
+ an Android package (application).
+
InstrumentationTestRunner
.
+
+ Will eventually support a superset of InstrumentationTestRunner
features,
+ while maintaining command/output format compatibility with that class.
+
+ TestCase
s and/or JUnit4 style
+
+ Test
s that perform tests against the classes in your package.
+ Make use of the InstrumentationRegistry
if needed.
+
+ In an appropriate AndroidManifest.xml, define an instrumentation with android:name set to
+ AndroidJUnitRunner
and the appropriate android:targetPackage
+ set.
+
+ Execution options:
+
+ Running all tests: adb shell am instrument -w
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Running all tests in a class: adb shell am instrument -w
+ -e class com.android.foo.FooTest
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Running a single test: adb shell am instrument -w
+ -e class com.android.foo.FooTest#testFoo
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Running all tests in multiple classes: adb shell am instrument -w
+ -e class com.android.foo.FooTest,com.android.foo.TooTest
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Running all tests listed in a file: adb shell am instrument -w
+ -e testFile /sdcard/tmp/testFile.txt com.android.foo/com.android.test.runner.AndroidJUnitRunner
+ The file should contain a list of line separated test classes and optionally methods (expected
+ format: com.android.foo.FooClassName#testMethodName).
+
+ Running all tests in a java package: adb shell am instrument -w
+ -e package com.android.foo.bar
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+ To debug your tests, set a break point in your code and pass:
+ -e debug true
+
+ Running a specific test size i.e. annotated with
+ SmallTest
or
+ MediumTest
or
+ LargeTest
:
+ adb shell am instrument -w -e size [small|medium|large]
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Filter test run to tests with given annotation: adb shell am instrument -w
+ -e annotation com.android.foo.MyAnnotation
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ If used with other options, the resulting test run will contain the intersection of the two
+ options.
+ e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both
+ the LargeTest
and "com.android.foo.MyAnnotation" annotations.
+
+ Filter test run to tests without given annotation: adb shell am instrument -w
+ -e notAnnotation com.android.foo.MyAnnotation
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ As above, if used with other options, the resulting test run will contain the intersection of
+ the two options.
+ e.g. "-e size large -e notAnnotation com.android.foo.MyAnnotation" will run tests with
+ the LargeTest
annotation that do NOT have the "com.android.foo.MyAnnotation" annotations.
+
+ Filter test run to tests without any of a list of annotations: adb shell am
+ instrument -w -e notAnnotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ Filter test run to a shard of all tests, where numShards is an integer greater than 0 and
+ shardIndex is an integer between 0 (inclusive) and numShards (exclusive): adb shell am
+ instrument -w -e numShards 4 -e shardIndex 1
+ com.android.foo/android.support.test.runner.AndroidJUnitRunner
+
+ To run in 'log only' mode
+ -e log true
+ This option will load and iterate through all test classes and methods, but will bypass actual
+ test execution. Useful for quickly obtaining info on the tests to be executed by an
+ instrumentation command.
+
+ To generate EMMA code coverage:
+ -e coverage true
+ Note: this requires an emma instrumented build. By default, the code coverage results file
+ will be saved in a /data/RunListener
s to observe the test run:
+ -e listener com.foo.Listener,com.foo.Listener2
+
+ OR, specify the multiple listeners in the AndroidManifest via a meta-data tag:
+ instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" ...
+ meta-data android:name="listener"
+ android:value="com.foo.Listener,com.foo.Listener2"
+
+ Set timeout (in milliseconds) that will be applied to each test:
+ -e timeout_msec 5000
+
+ Supported for both JUnit3 and JUnit4 style tests. For JUnit3 tests, this flag is the only way
+ to specify timeouts. For JUnit4 tests, this flag overrides timeouts specified via
+
+ org.junit.rules.Timeout
. Please note that in JUnit4
+
+ org.junit.Test#timeout()
+ annotation take precedence over both, this flag and
+
+ org.junit.Test#timeout()
+ annotation.
+
+ To disable Google Analytics:
+ -e disableAnalytics true
+
+
+
+
+
+
+Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | +ARGUMENT_TEST_CLASS | ++ + + + + | +
+ [Expand]
+ Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ ![]()
+
+
+
+
+ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Ensures all activities launched in this instrumentation are finished before the
+ instrumentation exits.
+
+
+
+
+
+ | |||||||||||
+ Sets up lifecycle monitoring, and argument registry.
+
+
+
+
+
+ | |||||||||||
+ This implementation of onStart() will guarantee that the Application's onCreate method
+ has completed when it returns.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Ensures all activities launched in this instrumentation are finished before the + instrumentation exits. +
+ Subclasses who override this method should do their finish processing and then call + super.finish to invoke this logic. Not waiting for all activities to finish() before exiting + can cause device wide instability. +
+InstantiationException + | + |
---|---|
IllegalAccessException + | + |
Sets up lifecycle monitoring, and argument registry. +
+ Subclasses must call up to onCreate(). This onCreate method does not call start() + it is the subclasses responsibility to call start if it desires. +
+This implementation of onStart() will guarantee that the Application's onCreate method + has completed when it returns. +
+ Subclasses should call super.onStart() before executing any code that touches the application + and it's state. +
+java.lang.Object | +|
↳ | + +android.support.test.runner.MonitoringInstrumentation.ActivityFinisher | +
Loops through all the activities that have not yet finished and explicitly calls finish + on them. +
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||
↳ | + +android.app.Instrumentation | +|
+ + | ↳ | + +android.support.test.runner.MonitoringInstrumentation | +
+
+ ![]()
+
+
+
+
+ AndroidJUnitRunner
+
+
+
+
+ |
An instrumentation that enables several advanced features and makes some hard guarantees about + the state of the application under instrumentation. +
+ A short list of these capabilities: +Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MonitoringInstrumentation.ActivityFinisher | ++ Loops through all the activities that have not yet finished and explicitly calls finish + on them. + + + + | +
+ [Expand]
+ Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ ![]()
+
+
+
+
+ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Ensures all activities launched in this instrumentation are finished before the
+ instrumentation exits.
+
+
+
+
+
+ | |||||||||||
+ Sets up lifecycle monitoring, and argument registry.
+
+
+
+
+
+ | |||||||||||
+ This implementation of onStart() will guarantee that the Application's onCreate method
+ has completed when it returns.
+
+
+
+
+
+ | |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Ensures we've onStopped() all activities which were onStarted().
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Ensures all activities launched in this instrumentation are finished before the + instrumentation exits. +
+ Subclasses who override this method should do their finish processing and then call + super.finish to invoke this logic. Not waiting for all activities to finish() before exiting + can cause device wide instability. +
+Sets up lifecycle monitoring, and argument registry. +
+ Subclasses must call up to onCreate(). This onCreate method does not call start() + it is the subclasses responsibility to call start if it desires. +
+This implementation of onStart() will guarantee that the Application's onCreate method + has completed when it returns. +
+ Subclasses should call super.onStart() before executing any code that touches the application + and it's state. +
+Ensures we've onStopped() all activities which were onStarted(). +
+ According to Activity's contract, the process is not killable between onStart and onStop. + Breaking this contract (which finish() will if you let it) can cause bad behaviour (including + a full restart of system_server). +
++ We give the app 2 seconds to stop all its activities, then we proceed. +
+android.support.test.runner.lifecycle.ActivityLifecycleCallback | +
Callback for monitoring activity lifecycle events. These callbacks are invoked on the main + thread, so any long operations or violating the strict mode policies should be avoided. +
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Called on the main thread after an activity has processed its lifecycle change event
+ (for example onResume or onStart)
+
+
+
+
+
+ |
Called on the main thread after an activity has processed its lifecycle change event + (for example onResume or onStart)
activity + | The activity | +
---|---|
stage + | its current stage. + | +
android.support.test.runner.lifecycle.ActivityLifecycleMonitor | +
Interface for tests to use when they need to query the activity lifecycle state. +
+ Activity lifecycle changes occur only on the UI thread - therefore listeners registered with + an ActivityLifecycleMonitor should expect to be invoked on the UI thread. The direct query + methods can only be called on the UI thread because otherwise they would not be able to return + consistent responses. +
++ Retrieve instances of the monitor thru ActivityLifecycleMonitorRegistry. +
++ Detecting these lifecycle states requires support from Instrumentation, therefore do not expect + an instance to be present under any arbitrary instrumentation. +
+ + + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Adds a new callback that will be notified when lifecycle changes occur.
+
+
+
+
+
+ | |||||||||||
+ Returns all activities in a given stage of their lifecycle.
+
+
+
+
+
+ | |||||||||||
+ Returns the current lifecycle stage of a given activity.
+
+
+
+
+
+ | |||||||||||
+ Removes a previously registered lifecycle callback.
+
+
+
+
+
+ |
Adds a new callback that will be notified when lifecycle changes occur. +
+ Implementors will not hold a strong ref to the callback, the code which registers callbacks + is responsible for this. Code which registers callbacks should responsibly + remove their callback when it is no longer needed. +
++ Callbacks are executed on the main thread of the application, and should take care not to + block or otherwise perform expensive operations as it will directly impact the application. +
callback + | an ActivityLifecycleCallback + | +
---|
Returns all activities in a given stage of their lifecycle. +
+ This method can only return a consistant and correct answer from the main thread, therefore + callers should always invoke it from the main thread and implementors are free to throw an + exception if the call is not made on the main thread. +
++ Implementors should ensure this method returns a consistant response if called from a + lifecycle callback also registered with this monitor (eg: it would be horriblely wrong if a + callback sees PAUSED and calls this method with the PAUSED and does not see its activity in + the response. +
++ Callers should be aware that the monitor implementation may not hold strong references to the + Activities in the application. Therefore stages which are considered end stages or eligible + for garbage collection on low memory situations may not return an instance of a particular + activity if it has been garbage collected.
stage + | the stage to query for. | +
---|
IllegalStateException + | if called from outside the main thread. + | +
---|
Returns the current lifecycle stage of a given activity. +
+ This method can only return a consistant and correct answer + from the main thread, therefore callers should always invoke + it from the main thread and implementors are free to throw an + exception if the call is not made on the main thread. +
++ Implementors should ensure this method returns a consistant response if called from a + lifecycle callback also registered with this monitor (eg: it would be horriblely wrong if a + callback sees PAUSED and calls this method with the same activity and gets RESUMED. +
activity + | an activity in this application. | +
---|
IllegalArgumentException + | if activity is unknown to the monitor. | +
---|---|
NullPointerException + | if activity is null. | +
IllegalStateException + | if called off the main thread. + | +
Removes a previously registered lifecycle callback. +
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.runner.lifecycle.Stage | +
An enumeration of the lifecycle stages an activity undergoes. +
+ See the Activity
javadoc for detailed documentation.
+
Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Stage | +CREATED | ++ Indicates that onCreate has been called. + + + + | +|||||||||
Stage | +DESTROYED | ++ Indicates that onDestroy has been called - system is shutting down the activity. + + + + | +|||||||||
Stage | +PAUSED | ++ Indicates that onPause has been called - activity is no longer in the foreground. + + + + | +|||||||||
Stage | +PRE_ON_CREATE | ++ Indicates that onCreate is being called before any onCreate code executes. + + + + | +|||||||||
Stage | +RESTARTED | ++ Indicates that onResume has been called - we have navigated back to the activity. + + + + | +|||||||||
Stage | +RESUMED | ++ Indicates that onResume has been called - activity is now visible to user. + + + + | +|||||||||
Stage | +STARTED | ++ Indicates that onStart has been called. + + + + | +|||||||||
Stage | +STOPPED | ++ Indicates that onStop has been called - activity is no longer visible to the user. + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Indicates that onCreate has been called.
Indicates that onDestroy has been called - system is shutting down the activity.
Indicates that onPause has been called - activity is no longer in the foreground.
Indicates that onCreate is being called before any onCreate code executes.
Indicates that onResume has been called - we have navigated back to the activity.
Indicates that onResume has been called - activity is now visible to user.
Indicates that onStart has been called.
Indicates that onStop has been called - activity is no longer visible to the user.
ActivityLifecycleCallback | ++ Callback for monitoring activity lifecycle events. + + + + | +
ActivityLifecycleMonitor | ++ Interface for tests to use when they need to query the activity lifecycle state. + + + + | +
Stage | ++ An enumeration of the lifecycle stages an activity undergoes. + + + + | +
AndroidJUnit4 | ++ Aliases the current default Android JUnit 4 class runner, for future-proofing. + + + + | +
AndroidJUnitRunner | +
+ An Instrumentation that runs JUnit3 and JUnit4 tests against
+ an Android package (application).
+
+
+
+ |
+
MonitoringInstrumentation | ++ An instrumentation that enables several advanced features and makes some hard guarantees about + the state of the application under instrumentation. + + + + | +
MonitoringInstrumentation.ActivityFinisher | ++ Loops through all the activities that have not yet finished and explicitly calls finish + on them. + + + + | +
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.By | +
By
is a utility class which enables the creation of BySelector
s in a concise
+ manner.
Its primary function is to provide static factory methods for constructing BySelector
s
+ using a shortened syntax. For example, you would use findObject(By.text("foo"))
rather
+ than findObject(new BySelector().text("foo"))
to select UI elements with the text value
+ "foo".
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Constructs a new
+
+ BySelector and sets the checkable criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the checked criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the class name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the class name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the class name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the class name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the clickable criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and copies the criteria from original .
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the depth criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the content description criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the content description criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the content description criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the content description criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the content description criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the enabled criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the focusable criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the focused criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and adds a child selector criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and adds a descendant selector criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and adds a descendant selector criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the long clickable criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the application package name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the application package name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the resource name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the resource id criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the resource name criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the scrollable criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the selected criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the text value criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the text value criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the text value criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the text value criteria.
+
+
+
+ | |||||||||||
+ Constructs a new
+
+ BySelector and sets the text value criteria.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Constructs a new BySelector
and sets the checkable criteria.
Constructs a new BySelector
and sets the checked criteria.
Constructs a new BySelector
and sets the class name criteria.
Constructs a new BySelector
and sets the class name criteria.
Constructs a new BySelector
and sets the class name criteria.
Constructs a new BySelector
and sets the class name criteria.
Constructs a new BySelector
and sets the clickable criteria.
Constructs a new BySelector
and copies the criteria from original
.
+
Constructs a new BySelector
and sets the depth criteria.
+
Constructs a new BySelector
and sets the content description criteria.
Constructs a new BySelector
and sets the content description criteria.
Constructs a new BySelector
and sets the content description criteria.
Constructs a new BySelector
and sets the content description criteria.
Constructs a new BySelector
and sets the content description criteria.
Constructs a new BySelector
and sets the enabled criteria.
Constructs a new BySelector
and sets the focusable criteria.
Constructs a new BySelector
and sets the focused criteria.
Constructs a new BySelector
and adds a child selector criteria.
Constructs a new BySelector
and adds a descendant selector criteria.
Constructs a new BySelector
and adds a descendant selector criteria.
Constructs a new BySelector
and sets the long clickable criteria.
Constructs a new BySelector
and sets the application package name criteria.
Constructs a new BySelector
and sets the application package name criteria.
Constructs a new BySelector
and sets the resource name criteria.
Constructs a new BySelector
and sets the resource id criteria.
Constructs a new BySelector
and sets the resource name criteria.
Constructs a new BySelector
and sets the scrollable criteria.
Constructs a new BySelector
and sets the selected criteria.
Constructs a new BySelector
and sets the text value criteria.
Constructs a new BySelector
and sets the text value criteria.
Constructs a new BySelector
and sets the text value criteria.
Constructs a new BySelector
and sets the text value criteria.
Constructs a new BySelector
and sets the text value criteria.
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.BySelector | +
A BySelector
specifies criteria for matching UI elements during a call to
+ findObject(BySelector)
.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Sets the search criteria to match elements that are checkable or not checkable.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are checked or unchecked.
+
+
+
+
+
+ | |||||||||||
+ Sets the class name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the class name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the class name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the class name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are clickable or not clickable.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are at a certain depth.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are in a range of depths.
+
+
+
+
+
+ | |||||||||||
+ Sets the content description criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the content description criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the content description criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the content description criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the content description criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are enabled or disabled.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are focusable or not focusable.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are focused or unfocused.
+
+
+
+
+
+ | |||||||||||
+ Adds a child selector criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Adds a descendant selector criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Adds a descendant selector criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are long clickable or not long clickable.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are no more than a certain depth.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are at least a certain depth.
+
+
+
+
+
+ | |||||||||||
+ Sets the application package name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the package name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the resource name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the resource name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the resource name criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are scrollable or not scrollable.
+
+
+
+
+
+ | |||||||||||
+ Sets the search criteria to match elements that are selected or not selected.
+
+
+
+
+
+ | |||||||||||
+ Sets the text value criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the text value criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the text value criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the text value criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Sets the text value criteria for matching.
+
+
+
+
+
+ | |||||||||||
+ Returns a
+
+ String representation of this BySelector .
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Sets the search criteria to match elements that are checkable or not checkable.
isCheckable + | Whether to match elements that are checkable or elements that are not + checkable. | +
---|
BySelector
.
+Sets the search criteria to match elements that are checked or unchecked.
isChecked + | Whether to match elements that are checked or elements that are unchecked. | +
---|
BySelector
.
+Sets the class name criteria for matching. A UI element will be considered a match if its
+ full class name matches the className
Pattern
and all other criteria for this
+ selector are met.
className + | The Pattern to be used for matching. |
+
---|
BySelector
.
+Sets the class name criteria for matching. A UI element will be considered a match if its
+ class name exactly matches the className
parameter and all other criteria for
+ this selector are met. If className
starts with a period, it is assumed to be in the
+ android.widget
package.
className + | The full class name value to match. | +
---|
BySelector
.
+Sets the class name criteria for matching. A UI element will be considered a match if its
+ class name matches clazz
and all other criteria for this selector are met.
clazz + | The class to match. | +
---|
BySelector
+Sets the class name criteria for matching. A UI element will be considered a match if its
+ package and class name exactly match the packageName
and className
parameters
+ and all other criteria for this selector are met.
packageName + | The package value to match. | +
---|---|
className + | The class name value to match. | +
BySelector
.
+Sets the search criteria to match elements that are clickable or not clickable.
isClickable + | Whether to match elements that are clickable or elements that are not + clickable. | +
---|
BySelector
.
+Sets the search criteria to match elements that are at a certain depth.
Sets the search criteria to match elements that are in a range of depths.
Sets the content description criteria for matching. A UI element will be considered a match
+ if its content description matches the contentDescription
Pattern
and all
+ other criteria for this selector are met.
contentDescription + | The Pattern to be used for matching. |
+
---|
BySelector
.
+Sets the content description criteria for matching. A UI element will be considered a match
+ if its content description exactly matches the contentDescription
parameter and all
+ other criteria for this selector are met.
contentDescription + | The exact value to match. | +
---|
BySelector
.
+Sets the content description criteria for matching. A UI element will be considered a match
+ if its content description contains the substring
parameter and all other criteria
+ for this selector are met.
substring + | The substring to match. | +
---|
BySelector
.
+Sets the content description criteria for matching. A UI element will be considered a match
+ if its content description ends with the substring
parameter and all other criteria
+ for this selector are met.
substring + | The substring to match. | +
---|
BySelector
.
+Sets the content description criteria for matching. A UI element will be considered a match
+ if its content description starts with the substring
parameter and all other criteria
+ for this selector are met.
substring + | The substring to match. | +
---|
BySelector
.
+Sets the search criteria to match elements that are enabled or disabled.
isEnabled + | Whether to match elements that are enabled or elements that are disabled. | +
---|
BySelector
.
+Sets the search criteria to match elements that are focusable or not focusable.
isFocusable + | Whether to match elements that are focusable or elements that are not + focusable. | +
---|
BySelector
.
+Sets the search criteria to match elements that are focused or unfocused.
isFocused + | Whether to match elements that are focused or elements that are unfocused. | +
---|
BySelector
.
+Adds a child selector criteria for matching. A UI element will be considered a match if it
+ has a child element (direct descendant) which matches the childSelector
and all
+ other criteria for this selector are met. If specified more than once, matches must be found
+ for all childSelector
s.
childSelector + | The selector used to find a matching child element. | +
---|
BySelector
.
+Adds a descendant selector criteria for matching. A UI element will be considered a match if
+ it has a descendant element which matches the descendantSelector
and all other
+ criteria for this selector are met. If specified more than once, matches must be found for
+ all descendantSelector
s.
descendantSelector + | The selector used to find a matching descendant element. | +
---|---|
maxDepth + | The maximum depth under the element to search the descendant. | +
BySelector
.
+Adds a descendant selector criteria for matching. A UI element will be considered a match if
+ it has a descendant element which matches the descendantSelector
and all other
+ criteria for this selector are met. If specified more than once, matches must be found for
+ all descendantSelector
s.
descendantSelector + | The selector used to find a matching descendant element. | +
---|
BySelector
.
+Sets the search criteria to match elements that are long clickable or not long clickable.
isLongClickable + | Whether to match elements that are long clickable or elements that are + not long clickable. | +
---|
BySelector
.
+Sets the search criteria to match elements that are no more than a certain depth.
Sets the search criteria to match elements that are at least a certain depth.
Sets the application package name criteria for matching. A UI element will be considered a
+ match if its application package name exactly matches the applicationPackage
+ parameter and all other criteria for this selector are met.
applicationPackage + | The exact value to match. | +
---|
BySelector
.
+Sets the package name criteria for matching. A UI element will be considered a match if its
+ application package name matches the applicationPackage
Pattern
and all other
+ criteria for this selector are met.
applicationPackage + | The Pattern to be used for matching. |
+
---|
BySelector
.
+Sets the resource name criteria for matching. A UI element will be considered a match if its
+ resource name exactly matches the resourceName
parameter and all other criteria for
+ this selector are met.
resourceName + | The exact value to match. | +
---|
BySelector
.
+Sets the resource name criteria for matching. A UI element will be considered a match if its
+ resource name matches the resourceName
Pattern
and all other criteria for
+ this selector are met.
resourceName + | The Pattern to be used for matching. |
+
---|
BySelector
.
+Sets the resource name criteria for matching. A UI element will be considered a match if its
+ resource package and resource id exactly match the resourcePackage
and
+ resourceId
parameters and all other criteria for this selector are met.
resourcePackage + | The resource package value to match. | +
---|---|
resourceId + | The resouce-id value to match. | +
BySelector
.
+Sets the search criteria to match elements that are scrollable or not scrollable.
isScrollable + | Whether to match elements that are scrollable or elements that are not + scrollable. | +
---|
BySelector
.
+Sets the search criteria to match elements that are selected or not selected.
isSelected + | Whether to match elements that are selected or elements that are not + selected. | +
---|
BySelector
.
+Sets the text value criteria for matching. A UI element will be considered a match if its
+ text value matches the textValue
Pattern
and all other criteria for this
+ selector are met.
textValue + | The Pattern to be used for matching. |
+
---|
BySelector
.
+Sets the text value criteria for matching. A UI element will be considered a match if its
+ text value exactly matches the textValue
parameter and all other criteria for this
+ selector are met.
textValue + | The exact value to match. | +
---|
BySelector
.
+Sets the text value criteria for matching. A UI element will be considered a match if its
+ text value contains the substring
parameter and all other criteria for this selector
+ are met.
substring + | The substring to match. | +
---|
BySelector
.
+Sets the text value criteria for matching. A UI element will be considered a match if its
+ text value ends with the substring
parameter and all other criteria for this selector
+ are met.
substring + | The substring to match. | +
---|
BySelector
.
+Sets the text value criteria for matching. A UI element will be considered a match if its
+ text value starts with the substring
parameter and all other criteria for this
+ selector are met.
substring + | The substring to match. | +
---|
BySelector
.
+Returns a String
representation of this BySelector
. The format is
+ "BySelector [<KEY>='<VALUE> ... ]". Each criteria is listed as a key-value pair
+ where the key is the name of the criteria expressed in all caps (e.g. CLAZZ, RES, etc).
+
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.Configurator | +
Allows you to set key parameters for running uiautomator tests. The new
+ settings take effect immediately and can be changed any time during a test run.
+
+ To modify parameters using Configurator, first obtain an instance by calling
+ getInstance()
. As a best practice, make sure you always save
+ the original value of any parameter that you are modifying. After running your
+ tests with the modified parameters, make sure to also restore
+ the original parameter values, otherwise this will impact other tests cases.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Gets the current timeout for waiting for an acknowledgment of generic
+ uiautomator actions, such as clicks, text setting, and menu presses.
+
+
+
+
+
+ | |||||||||||
+ Retrieves a singleton instance of Configurator.
+
+
+
+
+
+ | |||||||||||
+ Gets the current delay between key presses when injecting text input.
+
+
+
+
+
+ | |||||||||||
+ Gets the timeout for waiting for an acknowledgement of an
+ uiautomtor scroll swipe action.
+
+
+
+
+
+ | |||||||||||
+ Gets the current timeout used for waiting for the user interface to go
+ into an idle state.
+
+
+
+
+
+ | |||||||||||
+ Gets the current timeout for waiting for a widget to become visible in
+ the user interface so that it can be matched by a selector.
+
+
+
+
+
+ | |||||||||||
+ Sets the timeout for waiting for an acknowledgment of generic uiautomator
+ actions, such as clicks, text setting, and menu presses.
+
+
+
+
+
+ | |||||||||||
+ Sets a delay between key presses when injecting text input.
+
+
+
+
+
+ | |||||||||||
+ Sets the timeout for waiting for an acknowledgement of an
+ uiautomtor scroll swipe action.
+
+
+
+
+
+ | |||||||||||
+ Sets the timeout for waiting for the user interface to go into an idle
+ state before starting a uiautomator action.
+
+
+
+
+
+ | |||||||||||
+ Sets the timeout for waiting for a widget to become visible in the user
+ interface so that it can be matched by a selector.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Gets the current timeout for waiting for an acknowledgment of generic
+ uiautomator actions, such as clicks, text setting, and menu presses.
+
+ The acknowledgment is an AccessibilityEvent,
+ corresponding to an action, that lets the framework determine if the
+ action was successful. Generally, this timeout should not be modified.
+ See UiObject
Retrieves a singleton instance of Configurator.
Gets the current delay between key presses when injecting text input.
+ See setText(String)
Gets the timeout for waiting for an acknowledgement of an
+ uiautomtor scroll swipe action.
+
+ The acknowledgment is an AccessibilityEvent,
+ corresponding to the scroll action, that lets the framework determine if
+ the scroll action was successful. Generally, this timeout should not be modified.
+ See UiScrollable
Gets the current timeout used for waiting for the user interface to go
+ into an idle state.
+
+ By default, all core uiautomator objects except UiDevice
will perform
+ this wait before starting to search for the widget specified by the
+ object's UiSelector
. Once the idle state is detected or the
+ timeout elapses (whichever occurs first), the object will start to wait
+ for the selector to find a match.
+ See setWaitForSelectorTimeout(long)
Gets the current timeout for waiting for a widget to become visible in + the user interface so that it can be matched by a selector. + + Because user interface content is dynamic, sometimes a widget may not + be visible immediately and won't be detected by a selector. This timeout + allows the uiautomator framework to wait for a match to be found, up until + the timeout elapses.
Sets the timeout for waiting for an acknowledgment of generic uiautomator
+ actions, such as clicks, text setting, and menu presses.
+
+ The acknowledgment is an AccessibilityEvent,
+ corresponding to an action, that lets the framework determine if the
+ action was successful. Generally, this timeout should not be modified.
+ See UiObject
timeout + | Timeout value in milliseconds | +
---|
Sets a delay between key presses when injecting text input.
+ See setText(String)
delay + | Delay value in milliseconds | +
---|
Sets the timeout for waiting for an acknowledgement of an
+ uiautomtor scroll swipe action.
+
+ The acknowledgment is an AccessibilityEvent,
+ corresponding to the scroll action, that lets the framework determine if
+ the scroll action was successful. Generally, this timeout should not be modified.
+ See UiScrollable
timeout + | Timeout value in milliseconds | +
---|
Sets the timeout for waiting for the user interface to go into an idle
+ state before starting a uiautomator action.
+
+ By default, all core uiautomator objects except UiDevice
will perform
+ this wait before starting to search for the widget specified by the
+ object's UiSelector
. Once the idle state is detected or the
+ timeout elapses (whichever occurs first), the object will start to wait
+ for the selector to find a match.
+ See setWaitForSelectorTimeout(long)
timeout + | Timeout value in milliseconds | +
---|
Sets the timeout for waiting for a widget to become visible in the user + interface so that it can be matched by a selector. + + Because user interface content is dynamic, sometimes a widget may not + be visible immediately and won't be detected by a selector. This timeout + allows the uiautomator framework to wait for a match to be found, up until + the timeout elapses.
timeout + | Timeout value in milliseconds. | +
---|
java.lang.Object | +||
↳ | + +java.lang.Enum<E extends java.lang.Enum<E>> | +|
+ + | ↳ | + +android.support.test.uiautomator.Direction | +
An enumeration used to specify the primary direction of certain gestures.
+ + + + + +Enum Values | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Direction | +DOWN | ++ + + + + | +|||||||||
Direction | +LEFT | ++ + + + + | +|||||||||
Direction | +RIGHT | ++ + + + + | +|||||||||
Direction | +UP | ++ + + + + | +
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns the reverse of the given direction.
+
+
+
+
+
+ | |||||||||||
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Returns the reverse of the given direction.
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.EventCondition<R> | +
An EventCondition
is a condition which depends on an event or series of events having
+ occurred.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
android.support.test.uiautomator.IAutomationSupport | +
Provides auxiliary support for running test cases
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Allows the running test cases to send out interim status
+
+
+
+
+
+ |
Allows the running test cases to send out interim status
status + | status report, consisting of key value pairs | +
---|
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.SearchCondition<R> | +
A SearchCondition
is a condition that is satisfied by searching for UI elements.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +||||
↳ | + +java.lang.Throwable | +|||
+ + | ↳ | + +java.lang.Exception | +||
+ + | + + | ↳ | + +java.lang.RuntimeException | +|
+ + | + + | + + | ↳ | + +android.support.test.uiautomator.StaleObjectException | +
A StaleObjectException
exception is thrown when a UiObject2
is used after the
+ underlying View
has been destroyed. In this case, it is necessary to call
+ findObject(BySelector)
to obtain a new UiObject2
instance.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|||
↳ | + +android.app.Instrumentation | +||
+ + | ↳ | + +android.test.InstrumentationTestRunner | +|
+ + | + + | ↳ | + +android.support.test.uiautomator.UiAutomatorInstrumentationTestRunner | +
Test runner for UiAutomatorTestCase
s. Such tests are executed
+ on the device and have access to an applications context.
+
+ [Expand]
+ Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ ![]()
+
+
+
+
+ | |||||||||||
+
+ ![]()
+
+
+
+
+ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Perform initialization specific to UiAutomator test.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Perform initialization specific to UiAutomator test. It sets up the test case so that + it can access the UiDevice and gives it access to the command line arguments.
test + | UiAutomatorTestCase to initialize. + | +
---|
java.lang.Object | +||||
↳ | + +junit.framework.Assert | +|||
+ + | ↳ | + +junit.framework.TestCase | +||
+ + | + + | ↳ | + +android.test.InstrumentationTestCase | +|
+ + | + + | + + | ↳ | + +android.support.test.uiautomator.UiAutomatorTestCase | +
+
+ This class is deprecated.
+ It is no longer necessary to extend UiAutomatorTestCase. You can use
+ getInstance(Instrumentation)
from any test class as long as you have access to
+ an Instrumentation
instance.
+
+
UI Automator test case that is executed on the device.
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ This method is deprecated.
+ Use
+
+ sendStatus(int, Bundle) instead
+
+
+
+
+ | |||||||||||
+ Get command line parameters.
+
+
+
+
+
+ | |||||||||||
+ Get current instance of
+
+ UiDevice .
+
+
+
+ | |||||||||||
+
+ This method is deprecated.
+ Use
+
+ sleep(long) instead.
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
+
+ This method is deprecated.
+ Use sendStatus(int, Bundle)
instead
+
+
Provides support for running tests to report interim status
Get command line parameters. On the command line when passing -e key value
+ pairs, the Bundle
will have the key value pairs conveniently available to the
+ tests.
Get current instance of UiDevice
. Works similar to calling the static
+ getInstance()
from anywhere in the test classes.
+
+ This method is deprecated.
+ Use sleep(long)
instead.
+
+
Calls sleep(long)
to sleep
ms + | is in milliseconds. | +
---|
java.lang.Object | +||
↳ | + +android.support.test.uiautomator.UiObject | +|
+ + | ↳ | + +android.support.test.uiautomator.UiCollection | +
+
+ ![]()
+
+
+
+
+ UiScrollable
+
+
+
+
+ |
Used to enumerate a container's UI elements for the purpose of counting, + or targeting a sub elements by a child's text or description.
+ + + + + +
+ [Expand]
+ Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ ![]()
+
+
+
+
+ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Constructs an instance as described by the selector
+
+
+
+
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Searches for child UI element within the constraints of this UiCollection
+
+ UiSelector
+ selector.
+
+
+
+ | |||||||||||
+ Searches for child UI element within the constraints of this UiCollection
+
+ UiSelector
+ selector.
+
+
+
+ | |||||||||||
+ Searches for child UI element within the constraints of this UiCollection
+
+ UiSelector
+ selector.
+
+
+
+ | |||||||||||
+ Counts child UI element instances matching the
+
+ childPattern
+ argument.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Constructs an instance as described by the selector
Searches for child UI element within the constraints of this UiCollection UiSelector
+ selector.
+
+ It looks for any child matching the childPattern
argument that has
+ a child UI element anywhere within its sub hierarchy that has content-description text.
+ The returned UiObject will point at the childPattern
instance that matched the
+ search and not at the identifying child element that matched the content description.
childPattern + | UiSelector selector of the child pattern to match and return |
+
---|---|
text + | String of the identifying child contents of of the childPattern |
+
UiObject
pointing at and instance of childPattern
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Searches for child UI element within the constraints of this UiCollection UiSelector
+ selector.
+
+ It looks for any child matching the childPattern
argument that has
+ a child UI element anywhere within its sub hierarchy that is at the instance
+ specified. The operation is performed only on the visible items and no scrolling is performed
+ in this case.
childPattern + | UiSelector selector of the child pattern to match and return |
+
---|---|
instance + | int the desired matched instance of this childPattern |
+
UiObject
pointing at and instance of childPattern
UiObjectNotFoundException + | + |
---|
Searches for child UI element within the constraints of this UiCollection UiSelector
+ selector.
+
+ It looks for any child matching the childPattern
argument that has
+ a child UI element anywhere within its sub hierarchy that has text attribute =
+ text
. The returned UiObject will point at the childPattern
+ instance that matched the search and not at the identifying child element that matched the
+ text attribute.
childPattern + | UiSelector selector of the child pattern to match and return |
+
---|---|
text + | String of the identifying child contents of of the childPattern |
+
UiObject
pointing at and instance of childPattern
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Counts child UI element instances matching the childPattern
+ argument. The method returns the number of matching UI elements that are
+ currently visible. The count does not include items of a scrollable list
+ that are off-screen.
childPattern + | a UiSelector that represents the matching child UI
+ elements to count |
+
---|
UiCollection
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.UiDevice | +
UiDevice provides access to state information about the device. + You can also use this class to simulate user actions on the device, + such as pressing the d-pad or pressing the Home and Menu buttons.
+ + + + + +Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Clears the text from the last UI traversal event.
+
+
+
+
+
+ | |||||||||||
+ Perform a click at arbitrary coordinates specified by the user
+
+
+
+
+
+ | |||||||||||
+ Performs a swipe from one coordinate to another coordinate.
+
+
+
+
+
+ | |||||||||||
+ Helper method used for debugging to dump the current window's layout hierarchy.
+
+
+
+
+
+ | |||||||||||
+ Returns the first object to match the
+
+ selector criteria.
+
+
+
+ | |||||||||||
+ Returns a UiObject which represents a view that matches the specified selector criteria.
+
+
+
+
+
+ | |||||||||||
+ Returns all objects that match the
+
+ selector criteria.
+
+
+
+ | |||||||||||
+ Disables the sensors and freezes the device rotation at its
+ current rotation state.
+
+
+
+
+
+ | |||||||||||
+
+ This method is deprecated.
+ The results returned should be considered unreliable
+
+
+
+
+
+ | |||||||||||
+ Retrieves the name of the last package to report accessibility events.
+
+
+
+
+
+ | |||||||||||
+ Gets the height of the display, in pixels.
+
+
+
+
+
+ | |||||||||||
+ Returns the current rotation of the display, as defined in
+
+ Surface
+
+
+
+ | |||||||||||
+ Returns the display size in dp (device-independent pixel)
+
+ The returned display size is adjusted per screen rotation.
+
+
+
+
+
+ | |||||||||||
+ Gets the width of the display, in pixels.
+
+
+
+
+
+ | |||||||||||
+ Retrieves a singleton instance of UiDevice
+
+
+
+
+
+ | |||||||||||
+
+ This method is deprecated.
+ Should use
+
+ getInstance(Instrumentation) instead. This version hides
+ UiDevice's dependency on having an Instrumentation reference and is prone to misuse.
+
+
+
+ | |||||||||||
+ Retrieves the text from the last UI traversal event received.
+
+
+
+
+
+ | |||||||||||
+ Retrieves the product name of the device.
+
+
+
+
+
+ | |||||||||||
+ Checks if any registered
+
+ UiWatcher have triggered.
+
+
+
+ | |||||||||||
+ Returns whether there is a match for the given
+
+ selector criteria.
+
+
+
+ | |||||||||||
+ Checks if a specific registered
+
+ UiWatcher has triggered.
+
+
+
+ | |||||||||||
+ Check if the device is in its natural orientation.
+
+
+
+
+
+ | |||||||||||
+ Checks the power manager if the screen is ON.
+
+
+
+
+
+ | |||||||||||
+ Opens the notification shade.
+
+
+
+
+
+ | |||||||||||
+ Opens the Quick Settings shade.
+
+
+
+
+
+ | |||||||||||
+ Performs the provided
+
+ action and waits for the condition to be met.
+
+
+
+ | |||||||||||
+ Simulates a short press on the BACK button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the CENTER button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the DOWN button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the LEFT button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the RIGHT button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the UP button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the DELETE key.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the ENTER key.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the HOME button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press using a key code.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press using a key code.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the MENU button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the Recent Apps button.
+
+
+
+
+
+ | |||||||||||
+ Simulates a short press on the SEARCH button.
+
+
+
+
+
+ | |||||||||||
+ Registers a
+
+ UiWatcher to run automatically when the testing framework is unable to
+ find a match using a UiSelector .
+
+
+
+ | |||||||||||
+ Removes a previously registered
+
+ UiWatcher .
+
+
+
+ | |||||||||||
+ Resets a
+
+ UiWatcher that has been triggered.
+
+
+
+ | |||||||||||
+ This method forces all registered watchers to run.
+
+
+
+
+
+ | |||||||||||
+ Enables or disables layout hierarchy compression.
+
+
+
+
+
+ | |||||||||||
+ Simulates orienting the device to the left and also freezes rotation
+ by disabling the sensors.
+
+
+
+
+
+ | |||||||||||
+ Simulates orienting the device into its natural orientation and also freezes rotation
+ by disabling the sensors.
+
+
+
+
+
+ | |||||||||||
+ Simulates orienting the device to the right and also freezes rotation
+ by disabling the sensors.
+
+
+
+
+
+ | |||||||||||
+ This method simply presses the power button if the screen is ON else
+ it does nothing if the screen is already OFF.
+
+
+
+
+
+ | |||||||||||
+ Performs a swipe between points in the Point array.
+
+
+
+
+
+ | |||||||||||
+ Performs a swipe from one coordinate to another using the number of steps
+ to determine smoothness and speed.
+
+
+
+
+
+ | |||||||||||
+ Take a screenshot of current window and store it as PNG
+
+ Default scale of 1.0f (original size) and 90% quality is used
+ The screenshot is adjusted per screen rotation
+
+
+
+
+
+ | |||||||||||
+ Take a screenshot of current window and store it as PNG
+
+ The screenshot is adjusted per screen rotation
+
+
+
+
+
+ | |||||||||||
+ Re-enables the sensors and un-freezes the device rotation allowing its contents
+ to rotate with the device physical rotation.
+
+
+
+
+
+ | |||||||||||
+ Waits for given the
+
+ condition to be met.
+
+
+
+ | |||||||||||
+ Waits for the current application to idle.
+
+
+
+
+
+ | |||||||||||
+ Waits for the current application to idle.
+
+
+
+
+
+ | |||||||||||
+ Waits for a window content update event to occur.
+
+
+
+
+
+ | |||||||||||
+ This method simulates pressing the power button if the screen is OFF else
+ it does nothing if the screen is already ON.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Clears the text from the last UI traversal event.
+ See getLastTraversedText()
.
Perform a click at arbitrary coordinates specified by the user
x + | coordinate | +
---|---|
y + | coordinate | +
Performs a swipe from one coordinate to another coordinate. You can control + the smoothness and speed of the swipe by specifying the number of steps. + Each step execution is throttled to 5 milliseconds per step, so for a 100 + steps, the swipe will take around 0.5 seconds to complete.
startX + | X-axis value for the starting coordinate | +
---|---|
startY + | Y-axis value for the starting coordinate | +
endX + | X-axis value for the ending coordinate | +
endY + | Y-axis value for the ending coordinate | +
steps + | is the number of steps for the swipe action | +
Helper method used for debugging to dump the current window's layout hierarchy. + Relative file paths are stored the application's internal private storage location.
Returns the first object to match the selector
criteria.
Returns a UiObject which represents a view that matches the specified selector criteria.
Returns all objects that match the selector
criteria.
Disables the sensors and freezes the device rotation at its + current rotation state.
+ | RemoteException | +
---|---|
RemoteException + | + |
+
+ This method is deprecated.
+ The results returned should be considered unreliable
+
Retrieves the last activity to report accessibility events.
Retrieves the name of the last package to report accessibility events.
Gets the height of the display, in pixels. The size is adjusted based + on the current orientation of the display.
Returns the current rotation of the display, as defined in Surface
Returns the display size in dp (device-independent pixel) + + The returned display size is adjusted per screen rotation. Also this will return the actual + size of the screen, rather than adjusted per system decorations (like status bar).
Gets the width of the display, in pixels. The width and height details + are reported based on the current orientation of the display.
Retrieves a singleton instance of UiDevice
+
+ This method is deprecated.
+ Should use getInstance(Instrumentation)
instead. This version hides
+ UiDevice's dependency on having an Instrumentation reference and is prone to misuse.
+
Retrieves a singleton instance of UiDevice
Retrieves the text from the last UI traversal event received. + + You can use this method to read the contents in a WebView container + because the accessibility framework fires events + as each text is highlighted. You can write a test to perform + directional arrow presses to focus on different elements inside a WebView, + and call this method to get the text from each traversed element. + If you are testing a view container that can return a reference to a + Document Object Model (DOM) object, your test should use the view's + DOM instead.
Retrieves the product name of the device. + + This method provides information on what type of device the test is running on. This value is + the same as returned by invoking #adb shell getprop ro.product.name.
Checks if any registered UiWatcher
have triggered.
+
+ See registerWatcher(String, UiWatcher)
+ See hasWatcherTriggered(String)
Returns whether there is a match for the given selector
criteria.
Checks if a specific registered UiWatcher
has triggered.
+ See registerWatcher(String, UiWatcher)
. If a UiWatcher runs and its
+ checkForCondition()
call returned true
, then
+ the UiWatcher is considered triggered. This is helpful if a watcher is detecting errors
+ from ANR or crash dialogs and the test needs to know if a UiWatcher has been triggered.
Check if the device is in its natural orientation. This is determined by checking if the + orientation is at 0 or 180 degrees.
Checks the power manager if the screen is ON.
+ | RemoteException | +
---|---|
RemoteException + | + |
Opens the notification shade.
Opens the Quick Settings shade.
Performs the provided action
and waits for the condition
to be met.
action + | The Runnable action to perform. |
+
---|---|
condition + | The EventCondition to evaluate. |
+
timeout + | Maximum amount of time to wait in milliseconds. | +
Simulates a short press on the BACK button.
Simulates a short press on the CENTER button.
Simulates a short press on the DOWN button.
Simulates a short press on the LEFT button.
Simulates a short press on the RIGHT button.
Simulates a short press on the UP button.
Simulates a short press on the DELETE key.
Simulates a short press on the ENTER key.
Simulates a short press on the HOME button.
Simulates a short press using a key code.
+
+ See KeyEvent
.
keyCode + | the key code of the event. | +
---|---|
metaState + | an integer in which each bit set to 1 represents a pressed meta key | +
Simulates a short press using a key code.
+
+ See KeyEvent
Simulates a short press on the MENU button.
Simulates a short press on the Recent Apps button.
+ | RemoteException | +
---|---|
RemoteException + | + |
Simulates a short press on the SEARCH button.
Registers a UiWatcher
to run automatically when the testing framework is unable to
+ find a match using a UiSelector
. See runWatchers()
name + | to register the UiWatcher | +
---|---|
watcher + | UiWatcher |
+
Removes a previously registered UiWatcher
.
+
+ See registerWatcher(String, UiWatcher)
name + | used to register the UiWatcher | +
---|
Resets a UiWatcher
that has been triggered.
+ If a UiWatcher runs and its checkForCondition()
call
+ returned true
, then the UiWatcher is considered triggered.
+ See registerWatcher(String, UiWatcher)
This method forces all registered watchers to run.
+ See registerWatcher(String, UiWatcher)
Enables or disables layout hierarchy compression. + + If compression is enabled, the layout hierarchy derived from the Acessibility + framework will only contain nodes that are important for uiautomator + testing. Any unnecessary surrounding layout nodes that make viewing + and searching the hierarchy inefficient are removed.
compressed + | true to enable compression; else, false to disable | +
---|
Simulates orienting the device to the left and also freezes rotation
+ by disabling the sensors.
+
+ If you want to un-freeze the rotation and re-enable the sensors
+ see unfreezeRotation()
.
+ | RemoteException | +
---|---|
RemoteException + | + |
Simulates orienting the device into its natural orientation and also freezes rotation
+ by disabling the sensors.
+
+ If you want to un-freeze the rotation and re-enable the sensors
+ see unfreezeRotation()
.
+ | RemoteException | +
---|---|
RemoteException + | + |
Simulates orienting the device to the right and also freezes rotation
+ by disabling the sensors.
+
+ If you want to un-freeze the rotation and re-enable the sensors
+ see unfreezeRotation()
.
+ | RemoteException | +
---|---|
RemoteException + | + |
This method simply presses the power button if the screen is ON else + it does nothing if the screen is already OFF.
+ | RemoteException | +
---|---|
RemoteException + | + |
Performs a swipe between points in the Point array. Each step execution is throttled + to 5ms per step. So for a 100 steps, the swipe will take about 1/2 second to complete
segments + | is Point array containing at least one Point object | +
---|---|
segmentSteps + | steps to inject between two Points | +
Performs a swipe from one coordinate to another using the number of steps + to determine smoothness and speed. Each step execution is throttled to 5ms + per step. So for a 100 steps, the swipe will take about 1/2 second to complete.
steps + | is the number of move steps sent to the system | +
---|
Take a screenshot of current window and store it as PNG + + Default scale of 1.0f (original size) and 90% quality is used + The screenshot is adjusted per screen rotation
storePath + | where the PNG should be written to | +
---|
Take a screenshot of current window and store it as PNG + + The screenshot is adjusted per screen rotation
storePath + | where the PNG should be written to | +
---|---|
scale + | scale the screenshot down if needed; 1.0f for original size | +
quality + | quality of the PNG compression; range: 0-100 | +
Re-enables the sensors and un-freezes the device rotation allowing its contents + to rotate with the device physical rotation. During a test execution, it is best to + keep the device frozen in a specific orientation until the test case execution has completed.
RemoteException + | + |
---|
Waits for given the condition
to be met.
condition + | The SearchCondition to evaluate. |
+
---|---|
timeout + | Maximum amount of time to wait in milliseconds. | +
Waits for the current application to idle.
timeout + | in milliseconds | +
---|
Waits for the current application to idle. + Default wait timeout is 10 seconds
Waits for a window content update event to occur. + + If a package name for the window is specified, but the current window + does not have the same package name, the function returns immediately.
packageName + | the specified window package name (can be null ).
+ If null , a window update from any front-end window will end the wait |
+
---|---|
timeout + | the timeout for the wait | +
This method simulates pressing the power button if the screen is OFF else + it does nothing if the screen is already ON. + + If the screen was OFF and it just got turned ON, this method will insert a 500ms delay + to allow the device time to wake up and accept input.
+ | RemoteException | +
---|---|
RemoteException + | + |
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.UiObject | +
+
+ ![]()
+
+
+
+
+ UiCollection
+
+
+
+
+ |
+
+ ![]()
+
+
+
+
+ UiScrollable
+
+
+
+
+ |
A UiObject is a representation of a view. It is not in any way directly bound to a
+ view as an object reference. A UiObject contains information to help it
+ locate a matching view at runtime based on the UiSelector
properties specified in
+ its constructor. Once you create an instance of a UiObject, it can
+ be reused for different views that match the selector criteria.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | +FINGER_TOUCH_HALF_WIDTH | ++ + + + + | +|||||||||
int | +SWIPE_MARGIN_LIMIT | ++ + + + + | +|||||||||
long | +WAIT_FOR_EVENT_TMEOUT | +
+
+ This constant is deprecated.
+ use setScrollAcknowledgmentTimeout(long)
+
+
+
+
+ |
+ |||||||||
long | +WAIT_FOR_SELECTOR_POLL | ++ + + + + | +|||||||||
long | +WAIT_FOR_SELECTOR_TIMEOUT | +
+
+ This constant is deprecated.
+ use setWaitForSelectorTimeout(long)
+
+
+
+
+ |
+ |||||||||
long | +WAIT_FOR_WINDOW_TMEOUT | ++ + + + + | +
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ This constructor is deprecated.
+ Use
+
+ findObject(UiSelector) instead. This version hides
+ UiObject's dependency on UiDevice and is prone to misuse.
+
+
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Clears the existing text contents in an editable field.
+
+
+
+
+
+ | |||||||||||
+ Performs a click at the center of the visible bounds of the UI element represented
+ by this UiObject.
+
+
+
+
+
+ | |||||||||||
+ Performs a click at the center of the visible bounds of the UI element represented
+ by this UiObject and waits for window transitions.
+
+
+
+
+
+ | |||||||||||
+ Waits for window transitions that would typically take longer than the
+ usual default timeouts.
+
+
+
+
+
+ | |||||||||||
+ Clicks the bottom and right corner of the UI element
+
+
+
+
+
+ | |||||||||||
+ Clicks the top and left corner of the UI element
+
+
+
+
+
+ | |||||||||||
+ Drags this object to a destination UiObject.
+
+
+
+
+
+ | |||||||||||
+ Drags this object to arbitrary coordinates.
+
+
+
+
+
+ | |||||||||||
+ Check if view exists.
+
+
+
+
+
+ | |||||||||||
+ Returns the view's
+
+ bounds property.
+
+
+
+ | |||||||||||
+ Creates a new UiObject for a child view that is under the present UiObject.
+
+
+
+
+
+ | |||||||||||
+ Counts the child views immediately under the present UiObject.
+
+
+
+
+
+ | |||||||||||
+ Retrieves the
+
+ className property of the UI element.
+
+
+
+ | |||||||||||
+ Reads the
+
+ content_desc property of the UI element
+
+
+
+ | |||||||||||
+ Creates a new UiObject for a sibling view or a child of the sibling view,
+ relative to the present UiObject.
+
+
+
+
+
+ | |||||||||||
+ Reads the view's
+
+ package property
+
+
+
+ | |||||||||||
+ Debugging helper.
+
+
+
+
+
+ | |||||||||||
+ Reads the
+
+ text property of the UI element
+
+
+
+ | |||||||||||
+ Returns the visible bounds of the view.
+
+
+
+
+
+ | |||||||||||
+ Checks if the UI element's
+
+ checkable property is currently true.
+
+
+
+ | |||||||||||
+ Check if the UI element's
+
+ checked property is currently true
+
+
+
+ | |||||||||||
+ Checks if the UI element's
+
+ clickable property is currently true.
+
+
+
+ | |||||||||||
+ Checks if the UI element's
+
+ enabled property is currently true.
+
+
+
+ | |||||||||||
+ Check if the UI element's
+
+ focusable property is currently true.
+
+
+
+ | |||||||||||
+ Check if the UI element's
+
+ focused property is currently true
+
+
+
+ | |||||||||||
+ Check if the view's
+
+ long-clickable property is currently true
+
+
+
+ | |||||||||||
+ Check if the view's
+
+ scrollable property is currently true
+
+
+
+ | |||||||||||
+ Checks if the UI element's
+
+ selected property is currently true.
+
+
+
+ | |||||||||||
+ Long clicks the center of the visible bounds of the UI element
+
+
+
+
+
+ | |||||||||||
+ Long clicks bottom and right corner of the UI element
+
+
+
+
+
+ | |||||||||||
+ Long clicks on the top and left corner of the UI element
+
+
+
+
+
+ | |||||||||||
+ Performs a multi-touch gesture.
+
+
+
+
+
+ | |||||||||||
+ Generates a two-pointer gesture with arbitrary starting and ending points.
+
+
+
+
+
+ | |||||||||||
+ Performs a two-pointer gesture, where each pointer moves diagonally
+ toward the other, from the edges to the center of this UiObject .
+
+
+
+
+
+ | |||||||||||
+ Performs a two-pointer gesture, where each pointer moves diagonally
+ opposite across the other, from the center out towards the edges of the
+ this UiObject.
+
+
+
+
+
+ | |||||||||||
+ Sets the text in an editable field, after clearing the field's content.
+
+
+
+
+
+ | |||||||||||
+ Performs the swipe down action on the UiObject.
+
+
+
+
+
+ | |||||||||||
+ Performs the swipe left action on the UiObject.
+
+
+
+
+
+ | |||||||||||
+ Performs the swipe right action on the UiObject.
+
+
+
+
+
+ | |||||||||||
+ Performs the swipe up action on the UiObject.
+
+
+
+
+
+ | |||||||||||
+ Waits a specified length of time for a view to become visible.
+
+
+
+
+
+ | |||||||||||
+ Waits a specified length of time for a view to become undetectable.
+
+
+
+
+
+ |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Finds a matching UI element in the accessibility hierarchy, by
+ using the selector for this UiObject.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
+
+ This constant is deprecated.
+ use setScrollAcknowledgmentTimeout(long)
+
+
+
+ This constant is deprecated.
+ use setWaitForSelectorTimeout(long)
+
+
+
+ This constructor is deprecated.
+ Use findObject(UiSelector)
instead. This version hides
+ UiObject's dependency on UiDevice and is prone to misuse.
+
Constructs a UiObject to represent a view that matches the specified + selector criteria.
Clears the existing text contents in an editable field.
+
+ The UiSelector
of this object must reference a UI element that is editable.
+
+ When you call this method, the method sets focus on the editable field, selects all of its
+ existing content, and clears it by sending a DELETE key press
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs a click at the center of the visible bounds of the UI element represented + by this UiObject.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs a click at the center of the visible bounds of the UI element represented
+ by this UiObject and waits for window transitions.
+
+ This method differ from click()
only in that this method waits for a
+ a new window transition as a result of the click. Some examples of a window transition:
+
timeout + | timeout before giving up on waiting for a new window | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Waits for window transitions that would typically take longer than the
+ usual default timeouts.
+ See clickAndWaitForNewWindow(long)
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Clicks the bottom and right corner of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Clicks the top and left corner of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Drags this object to a destination UiObject. + The number of steps specified in your input parameter can influence the + drag speed, and varying speeds may impact the results. Consider + evaluating different speeds when using this method in your tests.
destObj + | the destination UiObject. | +
---|---|
steps + | usually 40 steps. You can increase or decrease the steps to change the speed. | +
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Drags this object to arbitrary coordinates. + The number of steps specified in your input parameter can influence the + drag speed, and varying speeds may impact the results. Consider + evaluating different speeds when using this method in your tests.
destX + | the X-axis coordinate. | +
---|---|
destY + | the Y-axis coordinate. | +
steps + | usually 40 steps. You can increase or decrease the steps to change the speed. | +
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if view exists.
+
+ This methods performs a waitForExists(long)
with zero timeout. This
+ basically returns immediately whether the view represented by this UiObject
+ exists or not. If you need to wait longer for this view, then see
+ waitForExists(long)
.
Returns the view's bounds
property. See getVisibleBounds()
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Creates a new UiObject for a child view that is under the present UiObject.
selector + | for child view to match | +
---|
UiObjectNotFoundException + | + |
---|
Counts the child views immediately under the present UiObject.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Retrieves the className
property of the UI element.
UiObjectNotFoundException + | if no match was found | +
---|
Reads the content_desc
property of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Creates a new UiObject for a sibling view or a child of the sibling view, + relative to the present UiObject.
selector + | for a sibling view or children of the sibling view | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Reads the view's package
property
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Debugging helper. A test can dump the properties of a selector as a string
+ to its logs if needed. getSelector().toString();
Reads the text
property of the UI element
UiObjectNotFoundException + | if no match could be found | +
---|
Returns the visible bounds of the view. + + If a portion of the view is visible, only the bounds of the visible portion are + reported.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Checks if the UI element's checkable
property is currently true.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if the UI element's checked
property is currently true
UiObjectNotFoundException + | + |
---|
Checks if the UI element's clickable
property is currently true.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Checks if the UI element's enabled
property is currently true.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if the UI element's focusable
property is currently true.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if the UI element's focused
property is currently true
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if the view's long-clickable
property is currently true
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Check if the view's scrollable
property is currently true
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Checks if the UI element's selected
property is currently true.
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Long clicks the center of the visible bounds of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Long clicks bottom and right corner of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Long clicks on the top and left corner of the UI element
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs a multi-touch gesture. You must specify touch coordinates for
+ at least 2 pointers. Each pointer must have all of its touch steps
+ defined in an array of MotionEvent.PointerCoords
. You can use this method to
+ specify complex gestures, like circles and irregular shapes, where each
+ pointer may take a different path.
+
+ To create a single point on a pointer's touch path:
+
+ PointerCoords p = new PointerCoords();
+ p.x = stepX;
+ p.y = stepY;
+ p.pressure = 1;
+ p.size = 1;
+
touches + | represents the pointers' paths. Each MotionEvent.PointerCoords
+ array represents a different pointer. Each MotionEvent.PointerCoords in an
+ array element represents a touch point on a pointer's path. |
+
---|
true
if all touch events for this gesture are injected successfully,
+ false
otherwiseGenerates a two-pointer gesture with arbitrary starting and ending points.
startPoint1 + | start point of pointer 1 | +
---|---|
startPoint2 + | start point of pointer 2 | +
endPoint1 + | end point of pointer 1 | +
endPoint2 + | end point of pointer 2 | +
steps + | the number of steps for the gesture. Steps are injected + about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete. | +
true
if all touch events for this gesture are injected successfully,
+ false
otherwisePerforms a two-pointer gesture, where each pointer moves diagonally + toward the other, from the edges to the center of this UiObject .
percent + | percentage of the object's diagonal length for the pinch gesture | +
---|---|
steps + | the number of steps for the gesture. Steps are injected + about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete. | +
true
if all touch events for this gesture are injected successfully,
+ false
otherwise+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs a two-pointer gesture, where each pointer moves diagonally + opposite across the other, from the center out towards the edges of the + this UiObject.
percent + | percentage of the object's diagonal length for the pinch gesture | +
---|---|
steps + | the number of steps for the gesture. Steps are injected + about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete. | +
true
if all touch events for this gesture are injected successfully,
+ false
otherwise+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Sets the text in an editable field, after clearing the field's content. + +
+ The UiSelector
selector of this object must reference a UI element that is editable.
+
+
+ When you call this method, the method sets focus on the editable field, clears its existing + content, then injects your specified text into the field. + +
+ If you want to capture the original contents of the field, call getText()
first.
+ You can then modify the text and use this method to update the field.
+
+
Improvements: + Post API Level 19 (KitKat release), the underlying implementation is updated to a dedicated + set text accessibility action, and it also now supports Unicode.
text + | string to set | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs the swipe down action on the UiObject. + The swipe gesture can be performed over any surface. The targeted + UI element does not need to be scrollable. + See also: +
steps + | indicates the number of injected move steps into the system. Steps are + injected about 5ms apart. So a 100 steps may take about 1/2 second to complete. | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs the swipe left action on the UiObject. + The swipe gesture can be performed over any surface. The targeted + UI element does not need to be scrollable. + See also: +
steps + | indicates the number of injected move steps into the system. Steps are + injected about 5ms apart. So a 100 steps may take about 1/2 second to complete. | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs the swipe right action on the UiObject. + The swipe gesture can be performed over any surface. The targeted + UI element does not need to be scrollable. + See also: +
steps + | indicates the number of injected move steps into the system. Steps are + injected about 5ms apart. So a 100 steps may take about 1/2 second to complete. | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Performs the swipe up action on the UiObject. + See also: +
steps + | indicates the number of injected move steps into the system. Steps are + injected about 5ms apart. So a 100 steps may take about 1/2 second to complete. | +
---|
+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Waits a specified length of time for a view to become visible. + + This method waits until the view becomes visible on the display, or + until the timeout has elapsed. You can use this method in situations where + the content that you want to select is not immediately displayed.
timeout + | the amount of time to wait (in milliseconds) | +
---|
Waits a specified length of time for a view to become undetectable.
+
+ This method waits until a view is no longer matchable, or until the
+ timeout has elapsed.
+
+ A view becomes undetectable when the UiSelector
of the object is
+ unable to find a match because the element has either changed its state or is no
+ longer displayed.
+
+ You can use this method when attempting to wait for some long operation
+ to compete, such as downloading a large file or connecting to a remote server.
timeout + | time to wait (in milliseconds) | +
---|
Finds a matching UI element in the accessibility hierarchy, by + using the selector for this UiObject.
timeout + | in milliseconds | +
---|
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.UiObject2 | +
A UiObject2
represents a UI element. Unlike UiObject
, it is bound to a particular
+ view instance and can become stale if the underlying view object is destroyed. As a result, it
+ may be necessary to call findObject(BySelector)
to obtain a new
+ UiObject2
instance if the UI changes significantly.
+
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Clears the text content if this object is an editable field.
+
+
+
+
+
+ | |||||||||||
+ Clicks on this object.
+
+
+
+
+
+ | |||||||||||
+ Clicks on this object, and waits for the given condition to become true.
+
+
+
+
+
+ | |||||||||||
+ Drags this object to the specified location.
+
+
+
+
+
+ | |||||||||||
+ Drags this object to the specified location.
+
+
+
+
+
+ | |||||||||||
+
+
+
+
+
+
+ | |||||||||||
+ Searches all elements under this object and returns the first object to match the criteria.
+
+
+
+
+
+ | |||||||||||
+ Searches all elements under this object and returns all objects that match the criteria.
+
+
+
+
+
+ | |||||||||||
+ Performs a fling gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a fling gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Returns the package name of the app that this object belongs to.
+
+
+
+
+
+ | |||||||||||
+ Returns the number of child elements directly under this object.
+
+
+
+
+
+ | |||||||||||
+ Returns a collection of the child elements directly under this object.
+
+
+
+
+
+ | |||||||||||
+ Returns the class name of the underlying
+
+ View represented by this
+ object.
+
+
+
+ | |||||||||||
+ Returns the content description for this object.
+
+
+
+
+
+ | |||||||||||
+ Returns this object's parent.
+
+
+
+
+
+ | |||||||||||
+ Returns the fully qualified resource name for this object's id.
+
+
+
+
+
+ | |||||||||||
+ Returns the text value for this object.
+
+
+
+
+
+ | |||||||||||
+ Returns the visible bounds of this object in screen coordinates.
+
+
+
+
+
+ | |||||||||||
+ Returns a point in the center of the visible bounds of this object.
+
+
+
+
+
+ | |||||||||||
+ Returns whether there is a match for the given criteria under this object.
+
+
+
+
+
+ | |||||||||||
+
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is checkable.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is checked.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is clickable.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is enabled.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is focusable.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is focused.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is long clickable.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is scrollable.
+
+
+
+
+
+ | |||||||||||
+ Returns whether this object is selected.
+
+
+
+
+
+ | |||||||||||
+ Performs a long click on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a pinch close gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a pinch close gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a pinch open gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a pinch open gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Recycle this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a scroll gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a scroll gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Sets the margins used for gestures in pixels.
+
+
+
+
+
+ | |||||||||||
+ Sets the margins used for gestures in pixels.
+
+
+
+
+
+ | |||||||||||
+ Sets the text content if this object is an editable field.
+
+
+
+
+
+ | |||||||||||
+ Performs a swipe gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Performs a swipe gesture on this object.
+
+
+
+
+
+ | |||||||||||
+ Waits for given the
+
+ condition to be met.
+
+
+
+ | |||||||||||
+ Waits for given the
+
+ condition to be met.
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Clears the text content if this object is an editable field.
Clicks on this object.
Clicks on this object, and waits for the given condition to become true.
Drags this object to the specified location.
dest + | The end point that this object should be dragged to. | +
---|---|
speed + | The speed at which to perform this gesture in pixels per second. + | +
Drags this object to the specified location.
dest + | The end point that this object should be dragged to. + | +
---|
Searches all elements under this object and returns the first object to match the criteria. +
Searches all elements under this object and returns all objects that match the criteria.
Performs a fling gesture on this object.
direction + | The direction in which to fling. | +
---|
Performs a fling gesture on this object.
direction + | The direction in which to fling. | +
---|---|
speed + | The speed at which to perform this gesture in pixels per second. | +
Returns the package name of the app that this object belongs to.
Returns the number of child elements directly under this object.
Returns a collection of the child elements directly under this object.
Returns the class name of the underlying View
represented by this
+ object.
+
Returns the content description for this object.
Returns this object's parent.
Returns the fully qualified resource name for this object's id.
Returns the text value for this object.
Returns the visible bounds of this object in screen coordinates.
Returns a point in the center of the visible bounds of this object.
Returns whether there is a match for the given criteria under this object.
Returns whether this object is checkable.
Returns whether this object is checked.
Returns whether this object is clickable.
Returns whether this object is enabled.
Returns whether this object is focusable.
Returns whether this object is focused.
Returns whether this object is long clickable.
Returns whether this object is scrollable.
Returns whether this object is selected.
Performs a long click on this object.
Performs a pinch close gesture on this object.
percent + | The size of the pinch as a percentage of this object's size. | +
---|---|
speed + | The speed at which to perform this gesture in pixels per second. + | +
Performs a pinch close gesture on this object.
percent + | The size of the pinch as a percentage of this object's size. + | +
---|
Performs a pinch open gesture on this object.
percent + | The size of the pinch as a percentage of this object's size. | +
---|---|
speed + | The speed at which to perform this gesture in pixels per second. + | +
Performs a pinch open gesture on this object.
percent + | The size of the pinch as a percentage of this object's size. + | +
---|
Recycle this object.
Performs a scroll gesture on this object.
direction + | The direction in which to scroll. | +
---|---|
percent + | The distance to scroll as a percentage of this object's visible size. | +
Performs a scroll gesture on this object.
direction + | The direction in which to scroll. | +
---|---|
percent + | The distance to scroll as a percentage of this object's visible size. | +
speed + | The speed at which to perform this gesture in pixels per second. | +
Sets the margins used for gestures in pixels.
Sets the margins used for gestures in pixels.
Sets the text content if this object is an editable field.
Performs a swipe gesture on this object.
direction + | The direction in which to swipe. | +
---|---|
percent + | The length of the swipe as a percentage of this object's size. | +
speed + | The speed at which to perform this gesture in pixels per second. + | +
Performs a swipe gesture on this object.
direction + | The direction in which to swipe. | +
---|---|
percent + | The length of the swipe as a percentage of this object's size. + | +
Waits for given the condition
to be met.
condition + | The UiObject2Condition to evaluate. |
+
---|---|
timeout + | Maximum amount of time to wait in milliseconds. | +
Waits for given the condition
to be met.
condition + | The SearchCondition to evaluate. |
+
---|---|
timeout + | Maximum amount of time to wait in milliseconds. | +
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.UiObject2Condition<R> | +
A UiObject2Condition
is a condition which is satisfied when a UiObject2
is in a
+ particular state.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|||
↳ | + +java.lang.Throwable | +||
+ + | ↳ | + +java.lang.Exception | +|
+ + | + + | ↳ | + +android.support.test.uiautomator.UiObjectNotFoundException | +
Generated in test runs when a UiSelector
selector could not be matched
+ to any UI element displayed.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
java.lang.Object | +|||
↳ | + +android.support.test.uiautomator.UiObject | +||
+ + | ↳ | + +android.support.test.uiautomator.UiCollection | +|
+ + | + + | ↳ | + +android.support.test.uiautomator.UiScrollable | +
UiScrollable is a UiCollection
and provides support for searching
+ for items in scrollable layout elements. This class can be used with
+ horizontally or vertically scrollable controls.
+ [Expand]
+ Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+
+ ![]()
+
+
+
+
+ |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Constructor.
+
+
+
+
+
+ |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Performs a backwards fling action with the default number of fling
+ steps (5).
+
+
+
+
+
+ | |||||||||||
+ Performs a forward fling with the default number of fling steps (5).
+
+
+
+
+
+ | |||||||||||
+ Performs a fling gesture to reach the beginning of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Performs a fling gesture to reach the end of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Searches for a child element in the present scrollable container.
+
+
+
+
+
+ | |||||||||||
+ Searches for a child element in the present scrollable container.
+
+
+
+
+
+ | |||||||||||
+ Searches for a child element in the present scrollable container that
+ matches the selector you provided.
+
+
+
+
+
+ | |||||||||||
+ Searches for a child element in the present scrollable
+ container.
+
+
+
+
+
+ | |||||||||||
+ Searches for a child element in the present scrollable container.
+
+
+
+
+
+ | |||||||||||
+ Gets the maximum number of scrolls allowed when performing a
+ scroll action in search of a child element.
+
+
+
+
+
+ | |||||||||||
+ Returns the percentage of a widget's size that's considered as a no-touch
+ zone when swiping.
+
+
+
+
+
+ | |||||||||||
+ Performs a backward scroll.
+
+
+
+
+
+ | |||||||||||
+ Performs a backward scroll with the default number of scroll steps (55).
+
+
+
+
+
+ | |||||||||||
+ Performs a forward scroll action on the scrollable layout element until
+ the content-description is found, or until swipe attempts have been exhausted.
+
+
+
+
+
+ | |||||||||||
+ Performs a forward scroll with the default number of scroll steps (55).
+
+
+
+
+
+ | |||||||||||
+ Performs a forward scroll.
+
+
+
+
+
+ | |||||||||||
+ Perform a scroll forward action to move through the scrollable layout
+ element until a visible item that matches the selector is found.
+
+
+
+
+
+ | |||||||||||
+ Perform a forward scroll action to move through the scrollable layout element until
+ a visible item that matches the
+
+ UiObject is found.
+
+
+
+ | |||||||||||
+ Performs a forward scroll action on the scrollable layout element until
+ the text you provided is visible, or until swipe attempts have been exhausted.
+
+
+
+
+
+ | |||||||||||
+ Scrolls to the beginning of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Scrolls to the beginning of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Scrolls to the end of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Scrolls to the end of a scrollable layout element.
+
+
+
+
+
+ | |||||||||||
+ Set the direction of swipes to be horizontal when performing scroll actions.
+
+
+
+
+
+ | |||||||||||
+ Set the direction of swipes to be vertical when performing scroll actions.
+
+
+
+
+
+ | |||||||||||
+ Sets the maximum number of scrolls allowed when performing a
+ scroll action in search of a child element.
+
+
+
+
+
+ | |||||||||||
+ Sets the percentage of a widget's size that's considered as no-touch
+ zone when swiping.
+
+
+
+
+
+ |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Used privately when performing swipe searches to decide if an element has become
+ visible or not.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ | |||||||||||
+ ![]()
+
+
+
+
+ |
Constructor.
container + | a UiSelector selector to identify the scrollable
+ layout element. |
+
---|
Performs a backwards fling action with the default number of fling + steps (5). If the swipe direction is set to vertical, + then the swipe will be performed from top to bottom. If the swipe + direction is set to horizontal, then the swipes will be performed from + left to right. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Performs a forward fling with the default number of fling steps (5). + If the swipe direction is set to vertical, then the swipes will be + performed from bottom to top. If the swipe + direction is set to horizontal, then the swipes will be performed from + right to left. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Performs a fling gesture to reach the beginning of a scrollable layout element. + The beginning can be at the top-most edge in the case of vertical controls, or + the left-most edge for horizontal controls. Make sure to take into + account devices configured with right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Performs a fling gesture to reach the end of a scrollable layout element. + The end can be at the bottom-most edge in the case of vertical controls, or + the right-most edge for horizontal controls. Make sure to take into + account devices configured with right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Searches for a child element in the present scrollable container.
+ The search first looks for a child element that matches the selector
+ you provided, then looks for the content-description in its children elements.
+ If both search conditions are fulfilled, the method returns a {@ link UiObject}
+ representing the element matching the selector (not the child element in its
+ subhierarchy containing the content-description). By default, this method performs a
+ scroll search.
+ See getChildByDescription(UiSelector, String, boolean)
childPattern + | UiSelector for a child in a scollable layout element |
+
---|---|
text + | Content-description to find in the children of
+ the childPattern match |
+
UiObject
representing the child element that matches the search conditions+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Searches for a child element in the present scrollable container. + The search first looks for a child element that matches the selector + you provided, then looks for the content-description in its children elements. + If both search conditions are fulfilled, the method returns a {@ link UiObject} + representing the element matching the selector (not the child element in its + subhierarchy containing the content-description).
childPattern + | UiSelector for a child in a scollable layout element |
+
---|---|
text + | Content-description to find in the children of
+ the childPattern match (may be a partial match) |
+
allowScrollSearch + | set to true if scrolling is allowed | +
UiObject
representing the child element that matches the search conditions+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Searches for a child element in the present scrollable container that + matches the selector you provided. The search is performed without + scrolling and only on visible elements.
childPattern + | UiSelector for a child in a scollable layout element |
+
---|---|
instance + | int number representing the occurance of
+ a childPattern match |
+
UiObject
representing the child element that matches the search conditionsUiObjectNotFoundException + | + |
---|
Searches for a child element in the present scrollable
+ container. The search first looks for a child element that matches the
+ selector you provided, then looks for the text in its children elements.
+ If both search conditions are fulfilled, the method returns a {@ link UiObject}
+ representing the element matching the selector (not the child element in its
+ subhierarchy containing the text). By default, this method performs a
+ scroll search.
+ See getChildByText(UiSelector, String, boolean)
childPattern + | UiSelector selector for a child in a scrollable layout element |
+
---|---|
text + | String to find in the children of the childPattern match |
+
UiObject
representing the child element that matches the search conditions+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Searches for a child element in the present scrollable container. The + search first looks for a child element that matches the + selector you provided, then looks for the text in its children elements. + If both search conditions are fulfilled, the method returns a {@ link UiObject} + representing the element matching the selector (not the child element in its + subhierarchy containing the text).
childPattern + | UiSelector selector for a child in a scrollable layout element |
+
---|---|
text + | String to find in the children of the childPattern match |
+
allowScrollSearch + | set to true if scrolling is allowed | +
UiObject
representing the child element that matches the search conditions+ | UiObjectNotFoundException | +
---|---|
UiObjectNotFoundException + | + |
Gets the maximum number of scrolls allowed when performing a
+ scroll action in search of a child element.
+ See getChildByDescription(UiSelector, String)
and
+ getChildByText(UiSelector, String)
.
Returns the percentage of a widget's size that's considered as a no-touch + zone when swiping. The no-touch zone is set as a percentage of a widget's total + width or height, denoting a margin around the swipable area of the widget. + Swipes must start and end inside this margin. This is important when the + widget being swiped may not respond to the swipe if started at a point + too near to the edge. The default is 10% from either edge.
Performs a backward scroll. If the swipe direction is set to vertical, + then the swipes will be performed from top to bottom. If the swipe + direction is set to horizontal, then the swipes will be performed from + left to right. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
steps + | number of steps. Use this to control the speed of the scroll action. | +
---|
UiObjectNotFoundException + | + |
---|
Performs a backward scroll with the default number of scroll steps (55). + If the swipe direction is set to vertical, + then the swipes will be performed from top to bottom. If the swipe + direction is set to horizontal, then the swipes will be performed from + left to right. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Performs a forward scroll action on the scrollable layout element until
+ the content-description is found, or until swipe attempts have been exhausted.
+ See setMaxSearchSwipes(int)
text + | content-description to find within the contents of this scrollable layout element. | +
---|
UiObjectNotFoundException + | + |
---|
Performs a forward scroll with the default number of scroll steps (55). + If the swipe direction is set to vertical, + then the swipes will be performed from bottom to top. If the swipe + direction is set to horizontal, then the swipes will be performed from + right to left. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Performs a forward scroll. If the swipe direction is set to vertical, + then the swipes will be performed from bottom to top. If the swipe + direction is set to horizontal, then the swipes will be performed from + right to left. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
steps + | number of steps. Use this to control the speed of the scroll action | +
---|
UiObjectNotFoundException + | + |
---|
Perform a scroll forward action to move through the scrollable layout
+ element until a visible item that matches the selector is found.
+
+ See scrollDescriptionIntoView(String)
and scrollTextIntoView(String)
.
selector + | UiSelector selector |
+
---|
UiObjectNotFoundException + | + |
---|
Perform a forward scroll action to move through the scrollable layout element until
+ a visible item that matches the UiObject
is found.
obj + | UiObject |
+
---|
UiObjectNotFoundException + | + |
---|
Performs a forward scroll action on the scrollable layout element until
+ the text you provided is visible, or until swipe attempts have been exhausted.
+ See setMaxSearchSwipes(int)
text + | test to look for | +
---|
UiObjectNotFoundException + | + |
---|
Scrolls to the beginning of a scrollable layout element. The beginning + can be at the top-most edge in the case of vertical controls, or the + left-most edge for horizontal controls. Make sure to take into account + devices configured with right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Scrolls to the beginning of a scrollable layout element. The beginning + can be at the top-most edge in the case of vertical controls, or the + left-most edge for horizontal controls. Make sure to take into account + devices configured with right-to-left languages like Arabic and Hebrew.
steps + | use steps to control the speed, so that it may be a scroll, or fling | +
---|
UiObjectNotFoundException + | + |
---|
Scrolls to the end of a scrollable layout element. The end can be at the + bottom-most edge in the case of vertical controls, or the right-most edge for + horizontal controls. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
steps + | use steps to control the speed, so that it may be a scroll, or fling | +
---|
UiObjectNotFoundException + | + |
---|
Scrolls to the end of a scrollable layout element. The end can be at the + bottom-most edge in the case of vertical controls, or the right-most edge for + horizontal controls. Make sure to take into account devices configured with + right-to-left languages like Arabic and Hebrew.
UiObjectNotFoundException + | + |
---|
Set the direction of swipes to be horizontal when performing scroll actions.
Set the direction of swipes to be vertical when performing scroll actions.
Sets the maximum number of scrolls allowed when performing a
+ scroll action in search of a child element.
+ See getChildByDescription(UiSelector, String)
and
+ getChildByText(UiSelector, String)
.
swipes + | the number of search swipes to perform until giving up | +
---|
Sets the percentage of a widget's size that's considered as no-touch + zone when swiping. + The no-touch zone is set as percentage of a widget's total width or height, + denoting a margin around the swipable area of the widget. Swipes must + always start and end inside this margin. This is important when the + widget being swiped may not respond to the swipe if started at a point + too near to the edge. The default is 10% from either edge.
swipeDeadZonePercentage + | is a value between 0 and 1 | +
---|
Used privately when performing swipe searches to decide if an element has become + visible or not.
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.UiSelector | +
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.
+ + + + + +Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Set the search criteria to match widgets that are checkable.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that
+ are currently checked (usually for checkboxes).
+
+
+
+
+
+ | |||||||||||
+ Adds a child UiSelector criteria to this selector.
+
+
+
+
+
+ | |||||||||||
+ 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.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the content-description
+ property for a widget.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the content-description
+ property for a widget.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the content-description
+ property for a widget.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the content-description
+ property for a widget.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that are enabled.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that are focusable.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that have focus.
+
+
+
+
+
+ | |||||||||||
+ Adds a child UiSelector criteria to this selector which is used to
+ start search from the parent widget.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the widget by its node
+ index in the layout hierarchy.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the
+ widget by its instance number.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that are long-clickable.
+
+
+
+
+
+ | |||||||||||
+ 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.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match widgets that
+ are currently selected.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the visible text displayed
+ in a widget (for example, the text label to launch an app).
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the visible text in a widget
+ where the visible text must contain the string in your input argument.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match the visible text displayed in a layout
+ element, using a regular expression.
+
+
+
+
+
+ | |||||||||||
+ Set the search criteria to match visible text in a widget that is
+ prefixed by the text parameter.
+
+
+
+
+
+ | |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
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.
val + | Value to match | +
---|
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.
val + | Value to match | +
---|
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").
className + | Value to match | +
---|
Set the search criteria to match the class property + for a widget (for example, "android.widget.Button").
type + | type | +
---|
Set the search criteria to match the class property + for a widget, using a regular expression.
regex + | 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.
val + | Value to match | +
---|
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.
desc + | Value to match | +
---|
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.
desc + | Value to match | +
---|
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.
regex + | a regular expression | +
---|
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.
desc + | Value to match | +
---|
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.
val + | Value to match | +
---|
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.
val + | Value to match | +
---|
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.
val + | Value to match | +
---|
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 instance(int)
method.
index + | Value to match | +
---|
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);
+
instance + | Value to match | +
---|
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.
val + | Value to match | +
---|
Set the search criteria to match the package name + of the application that contains the widget.
name + | Value to match | +
---|
Set the search criteria to match the package name + of the application that contains the widget.
regex + | a regular expression | +
---|
Set the search criteria to match the given resource ID.
id + | Value to match | +
---|
Set the search criteria to match the resource ID + of the widget, using a regular expression.
regex + | 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.
val + | Value to match | +
---|
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.
val + | Value to match | +
---|
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.
text + | Value to match | +
---|
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.
text + | Value to match | +
---|
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.
regex + | a regular expression | +
---|
Set the search criteria to match visible text in a widget that is + prefixed by the text parameter. + + The matching is case-insensitive.
text + | Value to match | +
---|
android.support.test.uiautomator.UiWatcher | +
See registerWatcher(String, UiWatcher)
on how to register a
+ a condition watcher to be called by the automation library. The automation library will
+ invoke checkForCondition() only when a regular API call is in retry mode because it is unable
+ to locate its selector yet. Only during this time, the watchers are invoked to check if there is
+ something else unexpected on the screen.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Custom handler that is automatically called when the testing framework is unable to
+ find a match using the
+
+ UiSelector
+
+ When the framework is in the process of matching a UiSelector and it
+ is unable to match any widget based on the specified criteria in the selector,
+ the framework will perform retries for a predetermined time, waiting for the display
+ to update and show the desired widget.
+
+
+
+ |
Custom handler that is automatically called when the testing framework is unable to
+ find a match using the UiSelector
+
+ When the framework is in the process of matching a UiSelector
and it
+ is unable to match any widget based on the specified criteria in the selector,
+ the framework will perform retries for a predetermined time, waiting for the display
+ to update and show the desired widget. While the framework is in this state, it will call
+ registered watchers' checkForCondition(). This gives the registered watchers a chance
+ to take a look at the display and see if there is a recognized condition that can be
+ handled and in doing so allowing the current test to continue.
+
+ An example usage would be to look for dialogs popped due to other background
+ processes requesting user attention and have nothing to do with the application
+ currently under test.
java.lang.Object | +|
↳ | + +android.support.test.uiautomator.Until | +
The Until
class provides factory methods for constructing common conditions.
+
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ Returns a condition that depends on a
+
+ UiObject2 's checkable state.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's checked state.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's clickable state.
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description contains the
+ given string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description ends with the
+ given string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description exactly matches
+ the given string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description matches the given
+ regex.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description matches the given
+ regex.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's content description starts with the
+ given string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's enabled state.
+
+
+
+ | |||||||||||
+ Returns a
+
+ SearchCondition that is satisfied when at least one element matching the
+ selector can be found.
+
+
+
+ | |||||||||||
+ Returns a
+
+ SearchCondition that is satisfied when at least one element matching the
+ selector can be found.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's focusable state.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's focused state.
+
+
+
+ | |||||||||||
+ Returns a
+
+ SearchCondition that is satisfied when no elements matching the selector
+ can be found.
+
+
+
+ | |||||||||||
+ Returns a
+
+ SearchCondition that is satisfied when at least one element matching the
+ selector can be found.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's long clickable state.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a new window having appeared.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a scroll having reached the end in the given
+
+
+ direction .
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's scrollable state.
+
+
+
+ | |||||||||||
+ Returns a condition that depends on a
+
+ UiObject2 's selected state.
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value contains the given string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value ends with the given
+ string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value exactly matches the given
+ string.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value matches the given regex.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value matches the given regex.
+
+
+
+
+
+ | |||||||||||
+ Returns a condition that is satisfied when the object's text value starts with the given
+ string.
+
+
+
+
+
+ |
+ [Expand]
+ Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
+ ![]()
+
+
+
+
+ |
Returns a condition that depends on a UiObject2
's checkable state.
isCheckable + | Whether the object should be checkable to satisfy this condition. + | +
---|
Returns a condition that depends on a UiObject2
's checked state.
isChecked + | Whether the object should be checked to satisfy this condition. + | +
---|
Returns a condition that depends on a UiObject2
's clickable state.
isClickable + | Whether the object should be clickable to satisfy this condition. + | +
---|
Returns a condition that is satisfied when the object's content description contains the + given string. +
Returns a condition that is satisfied when the object's content description ends with the + given string. +
Returns a condition that is satisfied when the object's content description exactly matches + the given string. +
Returns a condition that is satisfied when the object's content description matches the given + regex. +
Returns a condition that is satisfied when the object's content description matches the given + regex. +
Returns a condition that is satisfied when the object's content description starts with the + given string. +
Returns a condition that depends on a UiObject2
's enabled state.
isEnabled + | Whether the object should be enabled to satisfy this condition. + | +
---|
Returns a SearchCondition
that is satisfied when at least one element matching the
+ selector can be found. The condition will return the first matching element.
+
Returns a SearchCondition
that is satisfied when at least one element matching the
+ selector can be found. The condition will return all matching elements.
+
Returns a condition that depends on a UiObject2
's focusable state.
isFocusable + | Whether the object should be focusable to satisfy this condition. + | +
---|
Returns a condition that depends on a UiObject2
's focused state.
isFocused + | Whether the object should be focused to satisfy this condition. + | +
---|
Returns a SearchCondition
that is satisfied when no elements matching the selector
+ can be found.
+
Returns a SearchCondition
that is satisfied when at least one element matching the
+ selector can be found.
+
Returns a condition that depends on a UiObject2
's long clickable state.
isLongClickable + | Whether the object should be long clickable to satisfy this condition. + | +
---|
Returns a condition that depends on a new window having appeared.
Returns a condition that depends on a scroll having reached the end in the given
+ direction
.
direction + | The direction of the scroll. + | +
---|
Returns a condition that depends on a UiObject2
's scrollable state.
isScrollable + | Whether the object should be scrollable to satisfy this condition. + | +
---|
Returns a condition that depends on a UiObject2
's selected state.
isSelected + | Whether the object should be selected to satisfy this condition. + | +
---|
Returns a condition that is satisfied when the object's text value contains the given string. +
Returns a condition that is satisfied when the object's text value ends with the given + string. +
Returns a condition that is satisfied when the object's text value exactly matches the given + string. +
Returns a condition that is satisfied when the object's text value matches the given regex. +
Returns a condition that is satisfied when the object's text value matches the given regex. +
Returns a condition that is satisfied when the object's text value starts with the given + string. +
IAutomationSupport | ++ Provides auxiliary support for running test cases + + + + | +
UiWatcher | +
+ See registerWatcher(String, UiWatcher) on how to register a
+ a condition watcher to be called by the automation library.
+
+
+
+ |
+
By | +
+
|
+
BySelector | +
+ A BySelector specifies criteria for matching UI elements during a call to
+ findObject(BySelector) .
+
+
+
+ |
+
Configurator | ++ Allows you to set key parameters for running uiautomator tests. + + + + | +
EventCondition<R> | +
+ An EventCondition is a condition which depends on an event or series of events having
+ occurred.
+
+
+
+ |
+
SearchCondition<R> | +
+ A SearchCondition is a condition that is satisfied by searching for UI elements.
+
+
+
+ |
+
UiAutomatorInstrumentationTestRunner | +
+ Test runner for UiAutomatorTestCase s.
+
+
+
+ |
+
UiAutomatorTestCase | +
+
+ This class is deprecated.
+ It is no longer necessary to extend UiAutomatorTestCase. You can use
+ getInstance(Instrumentation) from any test class as long as you have access to
+ an Instrumentation instance.
+
+
+
+
+ |
+
UiCollection | ++ Used to enumerate a container's UI elements for the purpose of counting, + or targeting a sub elements by a child's text or description. + + + + | +
UiDevice | ++ UiDevice provides access to state information about the device. + + + + | +
UiObject | ++ A UiObject is a representation of a view. + + + + | +
UiObject2 | +
+ A UiObject2 represents a UI element.
+
+
+
+ |
+
UiObject2Condition<R> | +
+ A UiObject2Condition is a condition which is satisfied when a UiObject2 is in a
+ particular state.
+
+
+
+ |
+
UiScrollable | +
+ UiScrollable is a UiCollection and provides support for searching
+ for items in scrollable layout elements.
+
+
+
+ |
+
UiSelector | ++ 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. + + + + | +
Until | +
+ The Until class provides factory methods for constructing common conditions.
+
+
+
+ |
+
Direction | ++ An enumeration used to specify the primary direction of certain gestures. + + + + | +
StaleObjectException | +
+ A StaleObjectException exception is thrown when a UiObject2 is used after the
+ underlying View has been destroyed.
+
+
+
+ |
+
UiObjectNotFoundException | +
+ Generated in test runs when a UiSelector selector could not be matched
+ to any UI element displayed.
+
+
+
+ |
+
emulator
), and the Dalvik Debug Monitor S
an emulator instance or connected Android-powered device. It also provides access to the
device shell for advanced command-line operations.
- + The Android Testing Support Library provides an extensive framework for testing Android apps. + This library provides a set of APIs that allow you to quickly build and run test code for + your apps, including JUnit 4 and functional user interface (UI) tests. You can run tests + created using these APIs from the Android Studio IDE or from the command line. +
+ +The Android Testing Support library is available through the Android SDK Manager. + For more information, see Testing Support Library Setup +
+ ++ This page provides information about what tools are provided in the Android Testing Support + Library, how to use them in your testing environment, and information about library releases. +
+ ++ The Android Testing Support Library includes the following test automation tools: +
+ ++ The + {@code AndroidJUnitRunner} + class is a JUnit test runner that lets you + run JUnit 3 or JUnit 4-style test classes on Android devices, including those using the + Espresso and UI Automator testing frameworks. + The test runner handles loading your test package and the app under test + to a device, running your tests, and reporting test results. This class replaces the {@link + android.test.InstrumentationTestRunner} class, which only supports JUnit 3 tests. +
+ ++ The key features of this test runner include: +
+ +Requires Android 2.2 (API level 8) or higher.
+ ++ The test runner is compatible with your JUnit 3 and JUnit 4 (up to JUnit + 4.10) tests. However, you should avoid mixing JUnit 3 and and JUnit 4 test code in the same + package, as this might cause unexpected results. If you are creating an instrumented JUnit 4 + test class to run on a device or emulator, your test class must be prefixed with the + {@code @RunWith(AndroidJUnit4.class)} annotation. +
+ +The following code snippet shows how you might write an instrumented JUnit 4 test to validate + that the add operation in the {@code CalculatorActivity} class works correctly. +
+ ++import android.support.test.runner.AndroidJUnit4; +import android.support.test.runner.AndroidJUnitRunner; +import android.test.ActivityInstrumentationTestCase2; + +@RunWith(AndroidJUnit4.class) +public class CalculatorInstrumentationTest + extends ActivityInstrumentationTestCase2<CalculatorActivity> { + + @Before + public void setUp() throws Exception { + super.setUp(); + + // Injecting the Instrumentation instance is required + // for your test to run with AndroidJUnitRunner. + injectInstrumentation(InstrumentationRegistry.getInstrumentation()); + mActivity = getActivity(); + } + + @Test + public void typeOperandsAndPerformAddOperation() { + // Call the CalculatorActivity add() method and pass in some operand values, then + // check that the expected value is returned. + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } +} ++ +
+ You can use the + {@code InstrumentationRegistry} + class to access information related to your + test run. This class includes the {@link android.app.Instrumentation} object, target app {@link + android.content.Context} object, test app {@link android.content.Context} object, and the + command line arguments passed into your test. This data is useful when you are writing tests + using the UI Automator framework or when writing tests that have dependencies on the {@link + android.app.Instrumentation} or {@link android.content.Context} objects. +
+ ++ In your JUnit 4.x tests, you can use annotations to configure the test run. This feature + minimizes the need to add boilerplate and conditional code in your tests. In addition to the + standard annotations supported by JUnit 4, the test runner also supports Android-specific + annotations, including: +
+ ++ The test runner supports splitting a single test suite into multiple + shards, so you can easily run tests belonging to the same shard together as a group, + under the same {@link android.app.Instrumentation} instance. Each shard is identified by an + index number. When running tests, use the {@code -e numShards} option to specify the number + of separate shards to create and the {@code -e shardIndex} option to specify which shard to + run. +
+ ++ For example, to split the test suite into 10 shards and run only the tests grouped in the + second shard, use the following command: +
+ ++adb shell am instrument -w -e numShards 10 -e shardIndex 2+ +
+ To learn more about using this test runner, see the + API reference. +
+ ++ The Espresso testing framework provides a set of APIs to build UI tests to test user flows + within an app. These APIs let you write automated UI tests that are concise and that run + reliably. Espresso is well-suited for writing white box-style automated tests, where + the test code utilizes implementation code details from the app under test. +
+ ++ The key features of the Espresso testing framework include: +
+ +Requires Android 2.2 (API level 8) or higher.
+ ++ The {@code Espresso.onView()} + method lets you access a UI component in the target app and + interact with it. The method accepts a + {@code Matcher} argument and searches the view + hierarchy to locate a corresponding {@link android.view.View} instance that meets some given + criteria. You can refine searches by specifying such criteria as: +
+ ++ For example, to target a button that has the ID value of {@code my_button}, you can specify + a matcher like this: +
+ ++onView(withId(R.id.my_button));+ +
+ If the search is successful, the + {@code onView()} + method returns a reference which lets you + perform user actions and test assertions against the target view. +
+ ++ In an {@link android.widget.AdapterView} layout, the layout is dynamically populated with + children views at runtime. If the target view is inside a layout subclassed from {@link + android.widget.AdapterView} (such as a {@link android.widget.ListView} or {@link + android.widget.GridView}), the + {@code onView()} + method might not work because only a subset of + the layout’s views may be loaded in the current view hierarchy. +
+ ++ Instead, use the {@code Espresso.onData()} + method to access a target view element. The {@code Espresso.onData()} + method returns a reference which lets you perform user actions and test assertions against the + elements in an {@link android.widget.AdapterView}. +
+ ++ Typically, you test an app by performing some user interactions against the app’s user + interface. You can easily automate these actions in your test by using the + {@code ViewActions} + API. You can perform such UI interactions as: +
+ ++ For example, to simulate entering a string value and pressing a button to submit the value, + you can write an automated test script like this. The + {@code ViewInteraction.perform()} + and {@code DataInteraction.perform()} + methods take one or more + {@code ViewAction} + arguments and run the actions in the order provided. +
+ ++// Type text into an EditText view, then close the soft keyboard +onView(withId(R.id.editTextUserInput)) + .perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard()); + +// Press the button to submit the text change +onView(withId(R.id.changeTextBt)).perform(click());+ +
+ Tests on Android devices can fail randomly because of timing issues. This testing issue is + referred to as test flakiness. Prior to Espresso, the workaround was to insert a + sufficiently long sleep or timeout period into a test or to add code to keep retrying the + failing operation. The Espresso testing framework handles synchronization between the + {@link android.app.Instrumentation} and the UI thread; this removes the need for the previous + timing workarounds and ensures that your test actions and assertions run more reliably. +
+ ++ To learn more about using Espresso, see the + API reference. +
+ ++ The UI Automator testing framework provides a set of APIs to build UI tests that perform + interactions on user apps and system apps. The UI Automator APIs allows you to perform + operations such as opening the Settings menu or the app launcher in a test device. The UI + Automator testing framework is well-suited for writing black box-style automated + tests, where the test code does not rely on internal implementation details of the target + app. +
+ ++ The key features of the UI Automator testing framework include: +
+ +Requires Android 4.3 (API level 18) or higher.
+ ++ The {@code uiautomatorviewer} tool provides a convenient GUI to scan and analyze the UI + components currently displayed on an Android device. You can use this tool to inspect the + layout hierarchy and view the properties of UI components that are visible on the foreground + of the device. This information lets you create more fine-grained tests using UI Automator, + for example by creating a UI selector that matches a specific visible property. +
+ ++ The {@code uiautomatorviewer} tool is located in the {@code <android-sdk>/tools/} + directory. +
+ ++ The UI Automator testing framework provides a + {@code UiDevice} + class to access and perform operations on the device on which the target app is running. You + can call its methods to access device properties such as current orientation or display size. + The {@code UiDevice} + class also let you perform actions such as: +
+ ++ For example, to simulate a Home button press, call the {@code UiDevice.pressHome()} method. +
+ ++ The UI Automator APIs allow you to write robust tests without needing to know about the + implementation details of the app that you are targeting. You can use these APIs to capture + and manipulate UI components across multiple apps: +
+ ++ For example, the following code shows how you can write a test script that brings up the + default app launcher in the device: +
+ ++// Initialize UiDevice instance +mDevice = UiDevice.getInstance(getInstrumentation()); + +// Perform a short press on the HOME button +mDevice().pressHome(); + +// Bring up the default launcher by searching for +// a UI component that matches the content-description for the launcher button +UiObject allAppsButton = mDevice + .findObject(new UiSelector().description("Apps")); + +// Perform a click on the button to bring up the launcher +allAppsButton.clickAndWaitForNewWindow();+ +
+ To learn more about using UI Automator, see the + API reference. +
+ ++ The Android Testing Support Library package is included with the latest version of the + Android Support Repository, which you can obtain as a supplemental download through the + Android SDK Manager. +
+ ++ To download the Android Support Repository through the SDK Manager: +
+ ++ After downloading, the tool installs the Support Repository files to your existing Android + SDK directory. The library files are located in the following subdirectory of your SDK: + {@code <sdk>/extras/android/m2repository} directory. +
+ ++ The Android Testing Support Library classes are located under the + {@code android.support.test} package. +
+ ++ To use the Android Testing Support Library in your Gradle project, add these dependencies in + your {@code build.gradle} file: +
+ ++dependencies { + androidTestCompile 'com.android.support.test:testing-support-lib:0.1' + // Set this dependency to build and run Espresso tests + androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0' + // Set this dependency to build and run UI Automator tests + androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0' +}+ +
To set +{@code AndroidJUnitRunner} + as the default test instrumentation runner in your Gradle project, specify this dependency in + your {@code build.gradle} file:
+ ++android { + defaultConfig { + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } +}+ +
+ It is strongly recommended that you use the Android Testing Support Library together with the + Android Studio IDE. Android Studio offers capabilities that support test + development, such as: +
+ ++ For more information about Android Studio and to download it, see + Download Android Studio and SDK Tools. +
\ No newline at end of file diff --git a/docs/html/tools/testing/testing-tools.jd b/docs/html/tools/testing/testing-tools.jd new file mode 100644 index 0000000000000000000000000000000000000000..5e0a5bcd26fafaebcb2863d6b632554e61d5fe7f --- /dev/null +++ b/docs/html/tools/testing/testing-tools.jd @@ -0,0 +1,56 @@ +page.title=Android Testing Tools +@jd:body + ++ Testing is a critical software development activity because it helps you + improve the quality of your apps, ensure better user satisfaction, and + reduce overall development time spent on fixing defects. +
+ +The following sections describe tools that help + you test your mobile apps for the Android platform. + +