From 23f004f4c5e498ec5e4be4141734c1660f92fb28 Mon Sep 17 00:00:00 2001 From: quddusc Date: Fri, 14 Jun 2013 15:38:10 -0700 Subject: docs: Updated uiautomator developer guide documentation for JB MR2 release. Bug: 8224013,8223957,8223641,8223589,8223815,7738720,7538348 Change-Id: Id81ef4eec7c83ef8bfb8168e82fccc9d002fda99 --- docs/html/tools/help/uiautomator/Configurator.jd | 960 +++++ .../tools/help/uiautomator/IAutomationSupport.jd | 88 +- .../tools/help/uiautomator/UiAutomatorTestCase.jd | 21 - docs/html/tools/help/uiautomator/UiCollection.jd | 3 - docs/html/tools/help/uiautomator/UiDevice.jd | 3187 +++++++++-------- docs/html/tools/help/uiautomator/UiObject.jd | 3688 ++++++++++++-------- .../help/uiautomator/UiObjectNotFoundException.jd | 24 - docs/html/tools/help/uiautomator/UiScrollable.jd | 3621 ++++++++++--------- docs/html/tools/help/uiautomator/UiSelector.jd | 2020 ++++++----- docs/html/tools/help/uiautomator/UiWatcher.jd | 4 - docs/html/tools/help/uiautomator/index.jd | 34 +- docs/html/tools/tools_toc.cs | 1 + 12 files changed, 8024 insertions(+), 5627 deletions(-) create mode 100644 docs/html/tools/help/uiautomator/Configurator.jd diff --git a/docs/html/tools/help/uiautomator/Configurator.jd b/docs/html/tools/help/uiautomator/Configurator.jd new file mode 100644 index 000000000000..c898772216d6 --- /dev/null +++ b/docs/html/tools/help/uiautomator/Configurator.jd @@ -0,0 +1,960 @@ +page.title=Configurator +parent.title=uiautomator +parent.link=index.html + +@jd:body + + +
+
+Since API level 18 +
+
+ +

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.

+ + +

Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Public Methods
+ + + + + + long + + getActionAcknowledgmentTimeout() + +
Gets the current timeout for waiting for an acknowledgment of generic + uiautomator actions, such as clicks, text setting, and menu presses.
+ +
+ + + + static + + Configurator + + getInstance() + +
Retrieves a singleton instance of Configurator.
+ +
+ + + + + + long + + getKeyInjectionDelay() + +
Gets the current delay between key presses when injecting text input.
+ +
+ + + + + + long + + getScrollAcknowledgmentTimeout() + +
Gets the timeout for waiting for an acknowledgement of an + uiautomtor scroll swipe action.
+ +
+ + + + + + long + + getWaitForIdleTimeout() + +
Gets the current timeout used for waiting for the user interface to go + into an idle state.
+ +
+ + + + + + long + + getWaitForSelectorTimeout() + +
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.
+ +
+ + + + + + Configurator + + setActionAcknowledgmentTimeout(long timeout) + +
Sets the timeout for waiting for an acknowledgment of generic uiautomator + actions, such as clicks, text setting, and menu presses.
+ +
+ + + + + + Configurator + + setKeyInjectionDelay(long delay) + +
Sets a delay between key presses when injecting text input.
+ +
+ + + + + + Configurator + + setScrollAcknowledgmentTimeout(long timeout) + +
Sets the timeout for waiting for an acknowledgement of an + uiautomtor scroll swipe action.
+ +
+ + + + + + Configurator + + setWaitForIdleTimeout(long timeout) + +
Sets the timeout for waiting for the user interface to go into an idle + state before starting a uiautomator action.
+ +
+ + + + + + Configurator + + setWaitForSelectorTimeout(long timeout) + +
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
+ +From class + + java.lang.Object + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Methods

+ + + + + +
+

+ + public + + + + + long + + getActionAcknowledgmentTimeout + () +

+
+ +

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

+
+
Returns
+
  • current timeout in milliseconds
+
+
+
Since
+
  • Android API Level 18
+
+ +
+
+ + + + +
+

+ + public + static + + + + Configurator + + getInstance + () +

+
+ +

Retrieves a singleton instance of Configurator.

+
+
Returns
+
  • Configurator instance
+
+
+
Since
+
  • Android API Level 18
+
+ +
+
+ + + + +
+

+ + public + + + + + long + + getKeyInjectionDelay + () +

+
+ +

Gets the current delay between key presses when injecting text input. + See setText(String)

+
+
Returns
+
  • current delay in milliseconds
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + long + + getScrollAcknowledgmentTimeout + () +

+
+ +

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

+
+
Returns
+
  • current timeout in milliseconds
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + long + + getWaitForIdleTimeout + () +

+
+ +

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)

+
+
Returns
+
  • Current timeout value in milliseconds
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + long + + getWaitForSelectorTimeout + () +

+
+ +

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.

+
+
Returns
+
  • Current timeout value in milliseconds
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + Configurator + + setActionAcknowledgmentTimeout + (long timeout) +

+
+ +

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

+
+
Parameters
+ + + + +
timeout + Timeout value in milliseconds
+
+
+
Returns
+
  • self
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + Configurator + + setKeyInjectionDelay + (long delay) +

+
+ +

Sets a delay between key presses when injecting text input. + See setText(String)

+
+
Parameters
+ + + + +
delay + Delay value in milliseconds
+
+
+
Returns
+
  • self
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + Configurator + + setScrollAcknowledgmentTimeout + (long timeout) +

+
+ +

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

+
+
Parameters
+ + + + +
timeout + Timeout value in milliseconds
+
+
+
Returns
+
  • self
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + Configurator + + setWaitForIdleTimeout + (long timeout) +

+
+ +

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)

+
+
Parameters
+ + + + +
timeout + Timeout value in milliseconds
+
+
+
Returns
+
  • self
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + Configurator + + setWaitForSelectorTimeout + (long timeout) +

+
+ +

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.

+
+
Parameters
+ + + + +
timeout + Timeout value in milliseconds.
+
+
+
Returns
+
  • self
+
+
+
Since
+
  • Android API Level 18
+
+
+ + + + + + + + + + diff --git a/docs/html/tools/help/uiautomator/IAutomationSupport.jd b/docs/html/tools/help/uiautomator/IAutomationSupport.jd index 4120f2b95886..1e9e3017fe92 100644 --- a/docs/html/tools/help/uiautomator/IAutomationSupport.jd +++ b/docs/html/tools/help/uiautomator/IAutomationSupport.jd @@ -11,58 +11,8 @@ parent.link=index.html

- - - - -
- - - - - - - - - - - - - - - - -
- -

Summary

- - - - - - - - - - - - - - - - - - - - - - - - - - @@ -97,31 +47,6 @@ parent.link=index.html - - - - - - - - - - - - - - - - - - - - - - - - - @@ -149,20 +74,9 @@ parent.link=index.html sendStatus(int resultCode, Bundle status) -
-
-
- - -
-
- +

Allows the running test cases to send out interim status

- -
- - diff --git a/docs/html/tools/help/uiautomator/UiAutomatorTestCase.jd b/docs/html/tools/help/uiautomator/UiAutomatorTestCase.jd index 48c63ba71a23..0d8d1bc0354d 100644 --- a/docs/html/tools/help/uiautomator/UiAutomatorTestCase.jd +++ b/docs/html/tools/help/uiautomator/UiAutomatorTestCase.jd @@ -14,27 +14,6 @@ parent.link=index.html

- - - - - - - - - - - - - - - - - - - - -
diff --git a/docs/html/tools/help/uiautomator/UiCollection.jd b/docs/html/tools/help/uiautomator/UiCollection.jd index ed92ca7246a4..3fc32b73c68c 100644 --- a/docs/html/tools/help/uiautomator/UiCollection.jd +++ b/docs/html/tools/help/uiautomator/UiCollection.jd @@ -9,8 +9,6 @@ parent.link=index.html or targeting a sub elements by a child's text or description.

-
-

Summary

@@ -1267,5 +1265,4 @@ From class
- diff --git a/docs/html/tools/help/uiautomator/UiDevice.jd b/docs/html/tools/help/uiautomator/UiDevice.jd index 1c8805b0b5ba..574245efe107 100644 --- a/docs/html/tools/help/uiautomator/UiDevice.jd +++ b/docs/html/tools/help/uiautomator/UiDevice.jd @@ -5,17 +5,16 @@ parent.link=index.html +

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.

-

Class Overview

-

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.

+

Summary

- @@ -32,902 +31,968 @@ parent.link=index.html -
-

Summary

+ + +
Public Methods
+ + + + + + - -
Public Methods
+ void + + clearLastTraversedText() +
Clears the text from the last UI traversal event.
+
+ boolean + + click(int x, int y) +
Perform a click at arbitrary coordinates specified by the user
+
+ + - - - - - - - - - + - - - - + - - - - + - - - - + - - - - + - + + + + + + - - - + - - - - + - - - - + - - - - + - - - - + - - - - + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - - - - - - - + - - - - - - + + - - - - - - - - - - + - - - - - - + + - - - - - - - - - - + - - - - - - + + - - - - - - - - - - + - - - - - - + + - - - - - - - - - - + - - - - - - + + - - - - - - + - - - - - - + + + - - - - - - @@ -946,7 +1011,7 @@ parent.link=index.html
Inherited Methods
- + - - @@ -92,952 +130,1569 @@ parent.link=index.html - + - - - + - - - + - - - + - - - + - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - + - - + - - - - - - + - - - - - - + +
Public Methods
- -
- - - - - - void - - clearLastTraversedText() - -
Clears the text from the last UI traversal event.
- -
- - - - - - boolean + boolean - click(int x, int y) - -
Perform a click at arbitrary coordinates specified by the user
- +
+ drag(int startX, int startY, int endX, int endY, int steps) + +
Performs a swipe from one coordinate to another coordinate.
+
- - - - - - void + +
+ + + + + + void - dumpWindowHierarchy(String fileName) - + + dumpWindowHierarchy(String fileName) +
Helper method used for debugging to dump the current window's layout hierarchy.
- +
- - - - - - void + +
+ + + + + + void - freezeRotation() - + + freezeRotation() +
Disables the sensors and freezes the device rotation at its current rotation state.
- +
- - - - - - String + +
+ + + + + + String - getCurrentActivityName() - -
- - This method is deprecated. - The results returned should be considered unreliable
- +
+ getCurrentActivityName() + +
+ This method is deprecated. + The results returned should be considered unreliable
+
- - - - - - String + +
+ + + + + + String - getCurrentPackageName() - + + getCurrentPackageName() +
Retrieves the name of the last package to report accessibility events.
- +
- - - - - - int + +
+ + + + + + int - getDisplayHeight() - + + getDisplayHeight() +
Gets the height of the display, in pixels.
- + +
+ + + + + + int + + getDisplayRotation() + +
Returns the current rotation of the display, as defined in Surface
+
- - - - - - int + +
+ + + + + + Point - getDisplayRotation() - -
Returns the current rotation of the display, as defined in Surface@return
- +
+ getDisplaySizeDp() + +
Returns the display size in dp (device-independent pixel) + + The returned display size is adjusted per screen rotation.
+
- - - - - - int + +
+ + + + + + int - getDisplayWidth() - + + getDisplayWidth() +
Gets the width of the display, in pixels.
- +
- - - + +
+ + + static - - UiDevice + + UiDevice - getInstance() - + + getInstance() +
Retrieves a singleton instance of UiDevice
- +
- - - - - - String + +
+ + + + + + String - getLastTraversedText() - + + getLastTraversedText() +
Retrieves the text from the last UI traversal event received.
- +
- - - - - - String + +
+ + + + + + String - getProductName() - + + getProductName() +
Retrieves the product name of the device.
- +
- - - - - - boolean + +
+ + + + + + boolean - hasAnyWatcherTriggered() - + + hasAnyWatcherTriggered() +
Checks if any registered UiWatcher have triggered.
- +
- - - - - - boolean + +
+ + + + + + boolean - hasWatcherTriggered(String watcherName) - + + hasWatcherTriggered(String watcherName) +
Checks if a specific registered UiWatcher has triggered.
- + +
+ + + + + + boolean + + isNaturalOrientation() + +
Check if the device is in its natural orientation.
+ +
+ + + + + + boolean + + isScreenOn() + +
Checks the power manager if the screen is ON.
+ +
+ + + + + + boolean + + openNotification() + +
Opens the notification shade.
+ +
+ + + + + + boolean + + openQuickSettings() + +
Opens the Quick Settings shade.
+ +
+ + + + + + boolean + + pressBack() + +
Simulates a short press on the BACK button.
+ +
+ + + + + + boolean + + pressDPadCenter() + +
Simulates a short press on the CENTER button.
+ +
+ + + + + + boolean + + pressDPadDown() + +
Simulates a short press on the DOWN button.
+
- - - - - - boolean - - isNaturalOrientation() - -
Check if the device is in its natural orientation.
- + +
+ + + + + + boolean + + pressDPadLeft() + +
Simulates a short press on the LEFT button.
+ +
+ + + + + + boolean + + pressDPadRight() + +
Simulates a short press on the RIGHT button.
+ +
+ + + + + + boolean + + pressDPadUp() + +
Simulates a short press on the UP button.
+ +
+ + + + + + boolean + + pressDelete() + +
Simulates a short press on the DELETE key.
+ +
+ + + + + + boolean + + pressEnter() + +
Simulates a short press on the ENTER key.
+ +
+ + + + + + boolean + + pressHome() + +
Simulates a short press on the HOME button.
+ +
+ + + + + + boolean + + pressKeyCode(int keyCode, int metaState) + +
Simulates a short press using a key code.
+ +
+ + + + + + boolean + + pressKeyCode(int keyCode) + +
Simulates a short press using a key code.
+ +
+ + + + + + boolean + + pressMenu() + +
Simulates a short press on the MENU button.
+ +
+ + + + + + boolean + + pressRecentApps() + +
Simulates a short press on the Recent Apps button.
+ +
+ + + + + + boolean + + pressSearch() + +
Simulates a short press on the SEARCH button.
+ +
+ + + + + + void + + registerWatcher(String name, UiWatcher watcher) + +
Registers a UiWatcher to run automatically when the testing framework is unable to + find a match using a UiSelector.
+ +
+ + + + + + void + + removeWatcher(String name) + +
Removes a previously registered UiWatcher.
+ +
+ + + + + + void + + resetWatcherTriggers() + +
Resets a UiWatcher that has been triggered.
+ +
+ + + + + + void + + runWatchers() + +
This method forces all registered watchers to run.
+ +
+ + + + + + void + + setCompressedLayoutHeirarchy(boolean compressed) + +
Enables or disables layout hierarchy compression.
+ +
+ + + + + + void + + setOrientationLeft() + +
Simulates orienting the device to the left and also freezes rotation + by disabling the sensors.
+ +
+ + + + + + void + + setOrientationNatural() + +
Simulates orienting the device into its natural orientation and also freezes rotation + by disabling the sensors.
+ +
+ + + + + + void + + setOrientationRight() + +
Simulates orienting the device to the right and also freezes rotation + by disabling the sensors.
+ +
+ + + + + + void + + sleep() + +
This method simply presses the power button if the screen is ON else + it does nothing if the screen is already OFF.
+ +
+ + + + + + boolean + + swipe(Point[] segments, int segmentSteps) + +
Performs a swipe between points in the Point array.
+ +
+ + + + + + boolean + + swipe(int startX, int startY, int endX, int endY, int steps) + +
Performs a swipe from one coordinate to another using the number of steps + to determine smoothness and speed.
+
- - - - - - boolean - - isScreenOn() - -
Checks the power manager if the screen is ON.
- -
- -
- - - - - - boolean - - pressBack() - -
Simulates a short press on the BACK button.
- -
- - - - - - boolean - - pressDPadCenter() - -
Simulates a short press on the CENTER button.
- -
- - - - - - boolean + boolean - pressDPadDown() - -
Simulates a short press on the DOWN button.
- -
+ takeScreenshot(File storePath) +
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
- -
- - - - - - boolean - - pressDPadLeft() - -
Simulates a short press on the LEFT button.
-
- - - - - - boolean - - pressDPadRight() - -
Simulates a short press on the RIGHT button.
- -
- -
- - - - - - boolean - - pressDPadUp() - -
Simulates a short press on the UP button.
- -
- - - - - - boolean - - pressDelete() - -
Simulates a short press on the DELETE key.
- -
- - - - - - boolean + boolean - pressEnter() - -
Simulates a short press on the ENTER key.
- -
+ takeScreenshot(File storePath, float scale, int quality) + +
Take a screenshot of current window and store it as PNG + The screenshot is adjusted per screen rotation
- -
- - - - - - boolean - - pressHome() - -
Simulates a short press on the HOME button.
-
- - - - - - boolean - - pressKeyCode(int keyCode) - -
Simulates a short press using a key code.
- -
- -
- - - - - - boolean - - pressKeyCode(int keyCode, int metaState) - -
Simulates a short press using a key code.
- -
- - - - - - boolean - - pressMenu() - -
Simulates a short press on the MENU button.
- -
- - - - - - boolean + void - pressRecentApps() - -
Simulates a short press on the Recent Apps button.
- -
+ unfreezeRotation() +
Re-enables the sensors and un-freezes the device rotation allowing its contents + to rotate with the device physical rotation.
- -
- - - - - - boolean - - pressSearch() - -
Simulates a short press on the SEARCH button.
-
- - - - - - void - - registerWatcher(String name, UiWatcher watcher) - -
Registers a UiWatcher to run automatically when the testing framework is unable to - find a match using a UiSelector.
- -
- -
- - - - - - void - - removeWatcher(String name) - -
Removes a previously registered UiWatcher.
- -
- - - - - - void - - resetWatcherTriggers() - -
Resets a UiWatcher that has been triggered.
- -
- - - - - - void + void - runWatchers() - -
This method forces all registered watchers to run.
- -
+ waitForIdle(long timeout) +
Waits for the current application to idle.
- -
- - - - - - void - - setOrientationLeft() - -
Simulates orienting the device to the left and also freezes rotation - by disabling the sensors.
-
- - - - - - void - - setOrientationNatural() - -
Simulates orienting the device into its natural orientation and also freezes rotation - by disabling the sensors.
- -
- -
- - - - - - void - - setOrientationRight() - -
Simulates orienting the device to the right and also freezes rotation - by disabling the sensors.
- -
- - - - - - void - - sleep() - -
This method simply presses the power button if the screen is ON else - it does nothing if the screen is already OFF.
- -
- - - - - - boolean + void - swipe(Point[] segments, int segmentSteps) - -
Performs a swipe between points in the Point array.
- -
+ waitForIdle() +
Waits for the current application to idle.
- -
- - - - - - boolean - - swipe(int startX, int startY, int endX, int endY, int steps) - -
Performs a swipe from one coordinate to another using the number of steps - to determine smoothness and speed.
-
- - - - - - boolean - - takeScreenshot(File storePath, float scale, int quality) - -
Take a screenshot of current window and store it as PNG - The screenshot is adjusted per screen rotation
- -
- -
- - - - - - boolean - - takeScreenshot(File storePath) - -
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
- -
- - - - - - void + boolean - unfreezeRotation() - -
Re-enables the sensors and un-freezes the device rotation allowing its contents - to rotate with the device physical rotation.
- -
+ waitForWindowUpdate(String packageName, long timeout) +
Waits for a window content update event to occur.
- -
- - - - - - void - - waitForIdle(long time) - -
Waits for the current application to idle.
-
- - - - - - void - - waitForIdle() - -
Waits for the current application to idle.
- -
+ - -
- - - - - - boolean - - waitForWindowUpdate(String packageName, long timeout) - -
Waits for a window content update event to occur.
- -
- - - - - - void + void - wakeUp() - + + wakeUp() +
This method simulates pressing the power button if the screen is OFF else it does nothing if the screen is already ON.
- +
- + + +
+

+ + public + + + + + boolean + + drag + (int startX, int startY, int endX, int endY, int steps) +

+
+ +

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.

+
+
Parameters
+ + + + + + + + + + + + + + + + +
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
+
+
+
Returns
+
  • true if swipe is performed, false if the operation fails + or the coordinates are invalid
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + -
+

- public - - - - + public + + + + void dumpWindowHierarchy (String fileName)

-
+
+ -
- -
- +

Helper method used for debugging to dump the current window's layout hierarchy. The file root location is /data/local/tmp

@@ -1269,40 +1419,38 @@ From class
- + + +
+

+ + public + + + -
-

- - public - - - - void freezeRotation ()

-
+
+ -
- -
- +

Disables the sensors and freezes the device rotation at its current rotation state.

Throws
- +
- + @@ -1314,34 +1462,32 @@ From class - + -
+

- public - - - - + public + + + + String getCurrentActivityName ()

-
+
+ -
- -

-

- - This method is deprecated.
The results returned should be considered unreliable +

+ This method is deprecated.
+ The results returned should be considered unreliable

Retrieves the last activity to report accessibility events.

@@ -1353,31 +1499,29 @@ From class
- + -
+

- public - - - - + public + + + + String getCurrentPackageName ()

-
+
+ -
- -
- +

Retrieves the name of the last package to report accessibility events.

Returns
@@ -1388,31 +1532,29 @@ From class
- + -
+

- public - - - - + public + + + + int getDisplayHeight ()

-
+
+ -
- -
- +

Gets the height of the display, in pixels. The size is adjusted based on the current orientation of the display.

@@ -1424,65 +1566,84 @@ From class
- + -
+

- public - - - - + public + + + + int getDisplayRotation ()

-
-
+
+ +

Returns the current rotation of the display, as defined in Surface

+
+
+
Since
+
  • Android API Level 17
+
- - -
+ + + +
+

+ + public + + + + + Point + + getDisplaySizeDp + () +

- -

Returns the current rotation of the display, as defined in Surface@return

+ +

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).

-
Since
-
  • Android API Level 17
-
+
Returns
+
  • a Point containing the display size in dp +
+
+
+
Since
+
  • Android API Level 18
+
- + -
+

- public - - - - + public + + + + int getDisplayWidth ()

-
-
- -
- - - -
- +

Gets the width of the display, in pixels. The width and height details are reported based on the current orientation of the display.

@@ -1494,31 +1655,23 @@ From class
- + -
+

- public - static - - - - UiDevice + public + static + + + + UiDevice getInstance ()

-
-
- -
- - - -
- +

Retrieves a singleton instance of UiDevice

Returns
@@ -1529,31 +1682,29 @@ From class
- + -
+

- public - - - - + public + + + + String getLastTraversedText ()

-
+
+ -
- -
- +

Retrieves the text from the last UI traversal event received. You can use this method to read the contents in a WebView container @@ -1573,31 +1724,23 @@ From class

- + -
+

- public - - - - + public + + + + String getProductName ()

-
-
- -
- - - -
- +

Retrieves the product name of the device. This method provides information on what type of device the test is running on. This value is @@ -1607,38 +1750,36 @@ From class

  • product name of the device
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + boolean hasAnyWatcherTriggered ()

-
+
+ -
- -
- +

Checks if any registered UiWatcher have triggered. See registerWatcher(String, UiWatcher) @@ -1648,31 +1789,29 @@ From class

- + -
+

- public - - - - + public + + + + boolean hasWatcherTriggered (String watcherName)

-
+
+ -
- -
- +

Checks if a specific registered UiWatcher has triggered. See registerWatcher(String, UiWatcher). If a UiWatcher runs and its checkForCondition() call returned true, then @@ -1687,31 +1826,23 @@ From class

- + -
+

- public - - - - + public + + + + boolean isNaturalOrientation ()

-
-
- -
- - - -
- +

Check if the device is in its natural orientation. This is determined by checking if the orientation is at 0 or 180 degrees.

@@ -1719,38 +1850,36 @@ From class
  • true if it is in natural orientation
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + boolean isScreenOn ()

-
+
+ -
- -
- +

Checks the power manager if the screen is ON.

Returns
@@ -1758,11 +1887,11 @@ From class
Throws
-
RemoteException
RemoteException
+
- + @@ -1774,31 +1903,89 @@ From class - + -
+

- public - - - - + public + + + + + boolean + + openNotification + () +

+
+ +

Opens the notification shade.

+
+
Returns
+
  • true if successful, else return false
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + + boolean + + openQuickSettings + () +

+
+ +

Opens the Quick Settings shade.

+
+
Returns
+
  • true if successful, else return false
+
+
+
Since
+
  • Android API Level 18
+
+
+
+ + + + +
+

+ + public + + + + boolean pressBack ()

-
+
+ -
- -
- +

Simulates a short press on the BACK button.

Returns
@@ -1809,31 +1996,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDPadCenter ()

-
+
+ -
- -
- +

Simulates a short press on the CENTER button.

Returns
@@ -1844,31 +2029,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDPadDown ()

-
+
+ -
- -
- +

Simulates a short press on the DOWN button.

Returns
@@ -1879,31 +2062,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDPadLeft ()

-
+
+ -
- -
- +

Simulates a short press on the LEFT button.

Returns
@@ -1914,31 +2095,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDPadRight ()

-
+
+ -
- -
- +

Simulates a short press on the RIGHT button.

Returns
@@ -1949,31 +2128,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDPadUp ()

-
+
+ -
- -
- +

Simulates a short press on the UP button.

Returns
@@ -1984,31 +2161,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressDelete ()

-
+
+ -
- -
- +

Simulates a short press on the DELETE key.

Returns
@@ -2019,31 +2194,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressEnter ()

-
+
+ -
- -
- +

Simulates a short press on the ENTER key.

Returns
@@ -2054,31 +2227,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressHome ()

-
+
+ -
- -
- +

Simulates a short press on the HOME button.

Returns
@@ -2089,34 +2260,45 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressKeyCode - (int keyCode) + (int keyCode, int metaState)

-
+
+ -
- -
- +

Simulates a short press using a key code. - See KeyEvent

+ See KeyEvent.

+
+
Parameters
+
RemoteException
RemoteException
+ + + + + + +
keyCode + the key code of the event.
metaState + an integer in which each bit set to 1 represents a pressed meta key
+
Returns
  • true if successful, else return false
@@ -2126,47 +2308,32 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressKeyCode - (int keyCode, int metaState) + (int keyCode)

-
+
+ -
- -
- +

Simulates a short press using a key code. - See KeyEvent.

-
-
Parameters
- - - - - - - - - -
keyCodethe key code of the event.
metaStatean integer in which each bit set to 1 represents a pressed meta key
-
+ See KeyEvent

Returns
  • true if successful, else return false
@@ -2176,31 +2343,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressMenu ()

-
+
+ -
- -
- +

Simulates a short press on the MENU button.

Returns
@@ -2211,31 +2376,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean pressRecentApps ()

-
+
+ -
- -
- +

Simulates a short press on the Recent Apps button.

Returns
@@ -2243,11 +2406,11 @@ From class
Throws
- +
- + @@ -2259,31 +2422,29 @@ From class - + -
+

- public - - - - + public + + + + boolean pressSearch ()

-
+
+ -
- -
- +

Simulates a short press on the SEARCH button.

Returns
@@ -2294,42 +2455,40 @@ From class
- + -
+

- public - - - - + public + + + + void registerWatcher (String name, UiWatcher watcher)

-
+
+ -
- -
- +

Registers a UiWatcher to run automatically when the testing framework is unable to find a match using a UiSelector. See runWatchers()

Parameters
RemoteException
RemoteException
- + - +
namename to register the UiWatcher
watcherwatcher UiWatcher
@@ -2339,31 +2498,29 @@ From class
- + -
+

- public - - - - + public + + + + void removeWatcher (String name)

-
+
+ -
- -
- +

Removes a previously registered UiWatcher. See registerWatcher(String, UiWatcher)

@@ -2371,50 +2528,39 @@ From class
Parameters
- +
namename used to register the UiWatcher
-
-
Throws
- - - - -
- UiAutomationException
-
- + -
+

- public - - - - + public + + + + void resetWatcherTriggers ()

-
+
+ -
- -
- +

Resets a UiWatcher that has been triggered. If a UiWatcher runs and its checkForCondition() call returned true, then the UiWatcher is considered triggered. @@ -2424,31 +2570,29 @@ From class

- + -
+

- public - - - - + public + + + + void runWatchers ()

-
+
+ -
- -
- +

This method forces all registered watchers to run. See registerWatcher(String, UiWatcher)

@@ -2456,31 +2600,63 @@ From class
- + -
+

- public - - - - + public + + + + void - setOrientationLeft - () + setCompressedLayoutHeirarchy + (boolean compressed)

-
-
+
+ +

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.

+
+
Parameters
+ + + + +
compressed + true to enable compression; else, false to disable
+
+
+
Since
+
  • Android API Level 18
+
+
- - -
+ + + +
+

+ + public + + + + + void + + setOrientationLeft + () +

- +

Simulates orienting the device to the left and also freezes rotation by disabling the sensors. @@ -2488,11 +2664,11 @@ From class see unfreezeRotation().

Throws
- +
- + @@ -2500,38 +2676,30 @@ From class
RemoteException
RemoteException
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + void setOrientationNatural ()

-
-
- -
- - - -
- +

Simulates orienting the device into its natural orientation and also freezes rotation by disabling the sensors. @@ -2539,11 +2707,11 @@ From class see unfreezeRotation().

Throws
- +
- + @@ -2551,38 +2719,30 @@ From class
RemoteException
RemoteException
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + void setOrientationRight ()

-
-
- -
- - - -
- +

Simulates orienting the device to the right and also freezes rotation by disabling the sensors. @@ -2590,11 +2750,11 @@ From class see unfreezeRotation().

Throws
- +
- + @@ -2602,47 +2762,45 @@ From class
RemoteException
RemoteException
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + void sleep ()

-
+
+ -
- -
- +

This method simply presses the power button if the screen is ON else it does nothing if the screen is already OFF.

Throws
- +
- + @@ -2654,42 +2812,40 @@ From class - + -
+

- public - - - - + public + + + + boolean swipe (Point[] segments, int segmentSteps)

-
+
+ -
- -
- +

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

Parameters
RemoteException
RemoteException
- + - +
segmentssegments is Point array containing at least one Point object
segmentStepssegmentSteps steps to inject between two Points
@@ -2703,31 +2859,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean swipe (int startX, int startY, int endX, int endY, int steps)

-
+
+ -
- -
- +

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.

@@ -2735,7 +2889,7 @@ From class
Parameters
- +
stepssteps is the number of move steps sent to the system
@@ -2749,49 +2903,34 @@ From class
- + -
+

- public - - - - + public + + + + boolean takeScreenshot - (File storePath, float scale, int quality) + (File storePath)

-
-
- -
- - - -
- +

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

Parameters
- + - - - - - - - -
storePathstorePath where the PNG should be written to
scalescale the screenshot down if needed; 1.0f for original size
qualityquality of the PNG compression; range: 0-100
@@ -2799,49 +2938,48 @@ From class
  • true if screen shot is created successfully, false otherwise
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + boolean takeScreenshot - (File storePath) + (File storePath, float scale, int quality)

-
-
- -
- - - -
- +

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

Parameters
- + + + + + + +
storePathstorePath 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
@@ -2849,44 +2987,42 @@ From class
  • true if screen shot is created successfully, false otherwise
-
Since
-
  • Android API Level 17
-
+
Since
+
  • Android API Level 17
+
- + -
+

- public - - - - + public + + + + void unfreezeRotation ()

-
+
+ -
- -
- +

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.

Throws
- +
@@ -2898,62 +3034,67 @@ From class - + -
+

- public - - - - + public + + + + void waitForIdle - (long time) + (long timeout)

-
+
+ -
- -
- +

Waits for the current application to idle.

+
+
Parameters
+
RemoteException
+ + + +
timeout + in milliseconds
+
- + -
+

- public - - - - + public + + + + void waitForIdle ()

-
+
+ -
- -
- +

Waits for the current application to idle. Default wait timeout is 10 seconds

@@ -2961,31 +3102,29 @@ From class
- + -
+

- public - - - - + public + + + + boolean waitForWindowUpdate (String packageName, long timeout)

-
+
+ -
- -
- +

Waits for a window content update event to occur. If a package name for the window is specified, but the current window @@ -2994,12 +3133,12 @@ From class

Parameters
- + - +
packageNamepackageName the specified window package name (can be null). If null, a window update from any front-end window will end the wait
timeouttimeout the timeout for the wait
@@ -3014,31 +3153,29 @@ From class
- + -
+

- public - - - - + public + + + + void wakeUp ()

-
+
+ -
- -
- +

This method simulates pressing the power button if the screen is OFF else it does nothing if the screen is already ON. @@ -3046,11 +3183,11 @@ From class to allow the device time to wake up and accept input.

Throws
- +
- + @@ -3059,7 +3196,6 @@ From class - @@ -3069,5 +3205,4 @@ From class - diff --git a/docs/html/tools/help/uiautomator/UiObject.jd b/docs/html/tools/help/uiautomator/UiObject.jd index a22df50bcbe8..45007e0a1799 100644 --- a/docs/html/tools/help/uiautomator/UiObject.jd +++ b/docs/html/tools/help/uiautomator/UiObject.jd @@ -5,13 +5,14 @@ parent.link=index.html -

A UiObject is a representation of a user interface (UI) element. It is not in any way directly bound to a - UI element as an object reference. A UiObject holds information to help it - locate a matching UI element at runtime based on the UiSelector properties specified in - its constructor. Since a UiObject is a representative for a UI element, it can - be reused for different views with matching UI elements. -

+

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.

+

Summary

@@ -25,24 +26,61 @@ parent.link=index.html + +
RemoteException
RemoteException
-
+
+ + + + -

Summary

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Constants
intFINGER_TOUCH_HALF_WIDTH
intSWIPE_MARGIN_LIMIT
longWAIT_FOR_EVENT_TMEOUT + This constant is deprecated. + use setScrollAcknowledgmentTimeout(long) +
longWAIT_FOR_SELECTOR_POLL
longWAIT_FOR_SELECTOR_TIMEOUT + This constant is deprecated. + use setWaitForSelectorTimeout(long) +
longWAIT_FOR_WINDOW_TMEOUT
@@ -60,22 +98,22 @@ parent.link=index.html - +

- - - - - - + + + + + + + - UiObject(UiSelector selector) - -
Constructs a UiObject to represent a specific UI element matched by the specified - UiSelector selector properties.
- +
+ UiObject(UiSelector selector) + +
Constructs a UiObject to represent a view that matches the specified + selector criteria.
+
- - - - - - void + + + + + + + void - clearTextField() - + + clearTextField() +
Clears the existing text contents in an editable field.
- +
- - - - - - boolean + + + + + + + boolean - click() - + + click() +
Performs a click at the center of the visible bounds of the UI element represented by this UiObject.
- +
- - - - - - boolean + + + + + + + boolean - clickAndWaitForNewWindow(long timeout) - + + clickAndWaitForNewWindow(long timeout) +
Performs a click at the center of the visible bounds of the UI element represented by this UiObject and waits for window transitions.
- +
- - - - - - boolean + + + + + + + boolean - clickAndWaitForNewWindow() - -
See clickAndWaitForNewWindow(long) - This method is intended to reliably wait for window transitions that would typically take - longer than the usual default timeouts.
- +
+ clickAndWaitForNewWindow() + +
Waits for window transitions that would typically take longer than the + usual default timeouts.
+
- - - - - - boolean + + + + + + + boolean - clickBottomRight() - + + clickBottomRight() +
Clicks the bottom and right corner of the UI element
- +
- - - - - - boolean + + + + + + + boolean - clickTopLeft() - + + clickTopLeft() +
Clicks the top and left corner of the UI element
- +
- - - - - - boolean - - exists() - -
Check if UI element exists.
- -
- -
- - - - - - Rect - - getBounds() - -
Returns the UI element's bounds property.
- -
- - - - - - UiObject + + boolean - getChild(UiSelector selector) - -
Creates a new UiObject representing a child UI element of the element currently represented - by this UiObject.
- -
+ dragTo(UiObject destObj, int steps) +
Drags this object to a destination UiObject.
- -
- - - - - - int - - getChildCount() - -
Counts the child UI elements immediately under the UI element currently represented by - this UiObject.
-
- - - - - - String - - getContentDescription() - -
Reads the content_desc property of the UI element
- -
- -
- - - - - - UiObject - - getFromParent(UiSelector selector) - -
Creates a new UiObject representing a child UI element from the parent element currently - represented by this object.
- -
- - - - - - String + + boolean - getPackageName() - -
Reads the UI element's package property
- -
+ dragTo(int destX, int destY, int steps) +
Drags this object to arbitrary coordinates.
- -
- - - final - - - UiSelector - - getSelector() - -
Debugging helper.
-
- - - - - - String - - getText() - -
Reads the text property of the UI element
- -
- -
- - - - - - Rect - - getVisibleBounds() - -
Returns the visible bounds of the UI element.
- -
- - - - - - boolean + + boolean - isCheckable() - -
Check if the UI element's checkable property is currently true
- -
+ exists() +
Check if view exists.
- -
- - - - - - boolean - - isChecked() - -
Check if the UI element's checked property is currently true
-
- - - - - - boolean - - isClickable() - -
Check if the UI element's clickable property is currently true
- -
- -
- - - - - - boolean - - isEnabled() - -
Check if the UI element's enabled property is currently true
- -
- - - - - - boolean + + Rect - isFocusable() - -
Check if the UI element's focusable property is currently true
- -
+ getBounds() +
Returns the view's bounds property.
- -
- - - - - - boolean - - isFocused() - -
Check if the UI element's focused property is currently true
-
- - - - - - boolean - - isLongClickable() - -
Check if the UI element's long-clickable property is currently true
- -
- -
- - - - - - boolean - - isScrollable() - -
Check if the UI element's scrollable property is currently true
- -
- - - - - - boolean + + UiObject - isSelected() - -
Check if the UI element's selected property is currently true
- -
+ getChild(UiSelector selector) +
Creates a new UiObject for a child view that is under the present UiObject.
- -
- - - - - - boolean - - longClick() - -
Long clicks the center of the visible bounds of the UI element
-
- - - - - - boolean - - longClickBottomRight() - -
Long clicks bottom and right corner of the UI element
- -
- -
- - - - - - boolean - - longClickTopLeft() - -
Long clicks on the top and left corner of the UI element
- -
- - - - - - boolean + + int - setText(String text) - -
Sets the text in an editable field, after clearing the field's content.
- -
+ getChildCount() +
Counts the child views immediately under the present UiObject.
- -
- - - - - - boolean - - swipeDown(int steps) - -
Perform the action on the UI element that is represented by this object, Also see - #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), - #scrollForward().
-
- - - - - - boolean - - swipeLeft(int steps) - -
Perform the action on the UI element that is represented by this object.
- -
- -
- - - - - - boolean - - swipeRight(int steps) - -
Perform the action on the UI element that is represented by this object.
- -
- - - - - - boolean + + String - swipeUp(int steps) - -
Perform the action on the UI element that is represented by this UiObject.
- -
+ getClassName() +
Retrieves the className property of the UI element.
- -
- - - - - - boolean - - waitForExists(long timeout) - -
Waits a specified length of time for a UI element to become visible.
-
- - - - - - boolean - - waitUntilGone(long timeout) - -
Waits a specified length of time for a UI element to become undetectable.
- -
-
+ String + + + getContentDescription() +
Reads the content_desc property of the UI element
+ - - + + - + +
- [Expand] -
Inherited Methods
-
- -From class - java.lang.Object -
- - -
-
-
-
- + String + + + getText() +
Reads the text property of the UI element
+ + + - - + Rect + + + getVisibleBounds() - +
Returns the visible bounds of the view.
+ - - + + - -

Public Constructors

- + boolean
+ + + isCheckable() -
-

- - public - - - - - - - UiObject - (UiSelector selector) -

-
-
+
Checks if the UI element's checkable property is currently true.
-
- - + -
-
- -

Constructs a UiObject to represent a specific UI element matched by the specified - UiSelector selector properties.

-
-
+ + - - + boolean + + + isChecked() +
Check if the UI element's checked property is currently true
- - + -

Public Methods

+ + - -
+ + + + boolean + + + isClickable() + +
Checks if the UI element's clickable property is currently true.
+ + + + + + + + + + + + + boolean + + + isEnabled() + +
Checks if the UI element's enabled property is currently true.
+ + + + + + + + + + + + + boolean + + + isFocusable() + +
Check if the UI element's focusable property is currently true.
+ + + + + + + + + + + + + boolean + + + isFocused() + +
Check if the UI element's focused property is currently true
+ + + + + + + + + + + + + boolean + + + isLongClickable() + +
Check if the view's long-clickable property is currently true
+ + + + + + + + + + + + + boolean + + + isScrollable() + +
Check if the view's scrollable property is currently true
+ + + + + + + + + + + + + boolean + + + isSelected() + +
Checks if the UI element's selected property is currently true.
+ + + + + + + + + + + + + boolean + + + longClick() + +
Long clicks the center of the visible bounds of the UI element
+ + + + + + + + + + + + + boolean + + + longClickBottomRight() + +
Long clicks bottom and right corner of the UI element
+ + + + + + + + + + + + + boolean + + + longClickTopLeft() + +
Long clicks on the top and left corner of the UI element
+ + + + + + + + + + + + + boolean + + + performMultiPointerGesture(PointerCoords... touches) + +
Performs a multi-touch gesture.
+ + + + + + + + + + + + + boolean + + + performTwoPointerGesture(Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps) + +
Generates a two-pointer gesture with arbitrary starting and ending points.
+ + + + + + + + + + + + + boolean + + + pinchIn(int percent, int steps) + +
Performs a two-pointer gesture, where each pointer moves diagonally + toward the other, from the edges to the center of this UiObject .
+ + + + + + + + + + + + + boolean + + + pinchOut(int percent, int steps) + +
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.
+ + + + + + + + + + + + + boolean + + + setText(String text) + +
Sets the text in an editable field, after clearing the field's content.
+ + + + + + + + + + + + + boolean + + + swipeDown(int steps) + +
Performs the swipe down action on the UiObject.
+ + + + + + + + + + + + + boolean + + + swipeLeft(int steps) + +
Performs the swipe left action on the UiObject.
+ + + + + + + + + + + + + boolean + + + swipeRight(int steps) + +
Performs the swipe right action on the UiObject.
+ + + + + + + + + + + + + boolean + + + swipeUp(int steps) + +
Performs the swipe up action on the UiObject.
+ + + + + + + + + + + + + boolean + + + waitForExists(long timeout) + +
Waits a specified length of time for a view to become visible.
+ + + + + + + + + + + + + boolean + + + waitUntilGone(long timeout) + +
Waits a specified length of time for a view to become undetectable.
+ + + + + + + + + + + + + + + + + + + + + + +
Protected Methods
+ + + + + + AccessibilityNodeInfo + + findAccessibilityNodeInfo(long timeout) + +
Finds a matching UI element in the accessibility hierarchy, by + using the selector for this UiObject.
+ +
+ + + + + + + + + + + + + +
+ [Expand] +
Inherited Methods
+ +From class + + java.lang.Object + +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + +

Constants

+ + + + + + +
+

+ + protected + static + final + int + + FINGER_TOUCH_HALF_WIDTH +

+
+ + + + +
+
+ +

+ + +
+ Constant Value: + + + 20 + (0x00000014) + + +
+ +
+
+ + + + + +
+

+ + protected + static + final + int + + SWIPE_MARGIN_LIMIT +

+
+ + + + +
+
+ +

+ + +
+ Constant Value: + + + 5 + (0x00000005) + + +
+ +
+
+ + + + + +
+

+ + protected + static + final + long + + WAIT_FOR_EVENT_TMEOUT +

+
+ + + + +
+
+

+

+ This constant is deprecated.
+ use setScrollAcknowledgmentTimeout(long) + +

+

+ + +
+ Constant Value: + + + 3000 + (0x0000000000000bb8) + + +
+ +
+
+ + + + + +
+

+ + protected + static + final + long + + WAIT_FOR_SELECTOR_POLL +

+
+ + + + +
+
+ +

+ + +
+ Constant Value: + + + 1000 + (0x00000000000003e8) + + +
+ +
+
+ + + + + +
+

+ + protected + static + final + long + + WAIT_FOR_SELECTOR_TIMEOUT +

+
+ + + + +
+
+

+

+ This constant is deprecated.
+ use setWaitForSelectorTimeout(long) + +

+

+ + +
+ Constant Value: + + + 10000 + (0x0000000000002710) + + +
+ +
+
+ + + + + +
+

+ + protected + static + final + long + + WAIT_FOR_WINDOW_TMEOUT +

+
+ + + + +
+
+ +

+ + +
+ Constant Value: + + + 5500 + (0x000000000000157c) + + +
+ +
+
+ + + + + + + + + + + +

Public Constructors

+ + + + + +
+

+ + public + + + + + + + UiObject + (UiSelector selector) +

+
+
+ + + +
+
+ +

Constructs a UiObject to represent a view that matches the specified + selector criteria.

+ +
+
+ + + + + + + + + + + + + +

Public Methods

+ + + + + +
+

+ + public + + + + + void + + clearTextField + () +

+
+
+ + + +
+
+ +

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 first sets focus at the start edge of the field. + The method then simulates a long-press to select the existing text, and deletes the + selected text. + + If a "Select-All" option is displayed, the method will automatically attempt to use it + to ensure full text selection. + + Note that it is possible that not all the text in the field is selected; for example, + if the text contains separators such as spaces, slashes, at symbol etc. + Also, not all editable fields support the long-press functionality.

+
+
Throws
+ + + + + +
UiObjectNotFoundException +
+
+ +
+
+ + + + +
+

+ + public + + + + + boolean + + click + () +

+
+
+ + + +
+
+ +

Performs a click at the center of the visible bounds of the UI element represented + by this UiObject.

+
+
Returns
+
  • true id successful else false
+
+
+
Throws
+ + + + + +
UiObjectNotFoundException +
+
+ +
+
+ + + + +
+

+ + public + + + + + boolean + + clickAndWaitForNewWindow + (long timeout) +

+
+
+ + + +
+
+ +

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: +

  • launching a new activity
  • +
  • bringing up a pop-up menu
  • +
  • bringing up a dialog
  • +
    +
    Parameters
    + + + + +
    timeout + timeout before giving up on waiting for a new window
    +
    +
    +
    Returns
    +
    • true if the event was triggered, else false
    +
    +
    +
    Throws
    + + + + + +
    UiObjectNotFoundException +
    +
    + +
    +
    + + + + +

    - public - - - - - void + public + + + + + boolean - clearTextField + clickAndWaitForNewWindow ()

    -
    +
    + -
    - -
    - -

    Clears the existing text contents in an editable field. - The UiSelector of this object must reference a UI element that is editable. +

    Waits for window transitions that would typically take longer than the + usual default timeouts. + See clickAndWaitForNewWindow(long)

    +
    +
    Returns
    +
    • true if the event was triggered, else false
    +
    +
    +
    Throws
    + - When you call this method, the method first sets focus at the start edge of the field. - The method then simulates a long-press to select the existing text, and deletes the - selected text. + + + +
    UiObjectNotFoundException +
    +
    - If a "Select-All" option is displayed, the method will automatically attempt to use it - to ensure full text selection. +
    +
    - Note that it is possible that not all the text in the field is selected; for example, - if the text contains separators such as spaces, slashes, at symbol etc. - Also, not all editable fields support the long-press functionality.

    + + + +
    +

    + + public + + + + + boolean + + clickBottomRight + () +

    +
    +
    + + + +
    +
    + +

    Clicks the bottom and right corner of the UI element

    +
    +
    Returns
    +
    • true on success
    +
    Throws
    - +
    + @@ -1049,40 +1704,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - click + clickTopLeft ()

    -
    +
    + -
    - -
    - -

    Performs a click at the center of the visible bounds of the UI element represented - by this UiObject.

    + +

    Clicks the top and left corner of the UI element

    Returns
    -
    • true id successful else false
    +
    • true on success
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1094,101 +1747,192 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - clickAndWaitForNewWindow - (long timeout) + dragTo + (UiObject destObj, int steps)

    -
    -
    +
    + +

    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.

    +
    +
    Parameters
    +
    UiObjectNotFoundException
    + + + + + + +
    destObj + the destination UiObject.
    steps + usually 40 steps. You can increase or decrease the steps to change the speed.
    +
    +
    +
    Returns
    +
    • true if successful
    +
    +
    +
    Throws
    + + + + +
    UiObjectNotFoundException +
    +
    +
    +
    Since
    +
    • Android API Level 18
    +
    +
    - - - + + + +
    +

    + + public + + + + + boolean + + dragTo + (int destX, int destY, int steps) +

    - -

    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: -

  • launching a new activity
  • -
  • bringing up a pop-up menu
  • -
  • bringing up a dialog
  • +

    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.

    Parameters
    - - + + + + + + +
    timeouttimeout before giving up on waiting for a new windowdestX + the X-axis coordinate.
    destY + the Y-axis coordinate.
    steps + usually 40 steps. You can increase or decrease the steps to change the speed.
    Returns
    -
    • true if the event was triggered, else false
    +
    • true if successful
    - +
    +
    Since
    +
    • Android API Level 18
    +
    - + -
    +

    - public - - - - + public + + + + boolean - clickAndWaitForNewWindow + exists ()

    -
    +
    + + + +
    +
    +

    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
    +
    • true if the view represented by this UiObject does exist
    +
    + +
    - - + + + + +
    +

    + + public + + + + + Rect + + getBounds + () +

    +
    +
    + +
    - -

    See clickAndWaitForNewWindow(long) - This method is intended to reliably wait for window transitions that would typically take - longer than the usual default timeouts.

    + +

    Returns the view's bounds property. See getVisibleBounds()

    Returns
    -
    • true if the event was triggered, else false
    +
    • Rect
    Throws
    - +
    + @@ -1200,43 +1944,46 @@ From class - + -
    +

    - public - - - - - boolean + public + + + + + UiObject - clickBottomRight - () + getChild + (UiSelector selector)

    -
    +
    + -
    - -
    - -

    Clicks the bottom and right corner of the UI element

    + +

    Creates a new UiObject for a child view that is under the present UiObject.

    +
    +
    Parameters
    +
    UiObjectNotFoundException
    + + + +
    selector + for child view to match
    +
    Returns
    -
    • true on success
    +
    • a new UiObject representing the child view
    Throws
    - - - - +
    Exception -
    @@ -1248,43 +1995,38 @@ From class - + -
    +

    - public - - - - - boolean + public + + + + + int - clickTopLeft + getChildCount ()

    -
    +
    + -
    - -
    - -

    Clicks the top and left corner of the UI element

    + +

    Counts the child views immediately under the present UiObject.

    Returns
    -
    • true on success
    +
    • the count of child views.
    Throws
    -
    UiObjectNotFoundException
    - - - +
    Exception -
    + @@ -1296,134 +2038,130 @@ From class - + -
    +

    - public - - - - - boolean + public + + + + + String - exists + getClassName ()

    -
    -
    - -
    - - - -
    - -

    Check if UI element exists. - This methods performs a waitForExists(long) with zero timeout. This - basically returns immediately whether the UI element represented by this UiObject - exists or not. If you need to wait longer for this UI element, then see - waitForExists(long).

    +

    Retrieves the className property of the UI element.

    Returns
    -
    • true if the UI element represented by this UiObject does exist -
    +
    • class name of the current node represented by this UiObject
    +
    +
    +
    Throws
    +
    UiObjectNotFoundException
    + + + +
    UiObjectNotFoundException + if no match was found
    +
    +
    +
    Since
    +
    • Android API Level 18
    -
    - + -
    +

    - public - - - - - Rect + public + + + + + String - getBounds + getContentDescription ()

    -
    +
    + -
    - -
    - -

    Returns the UI element's bounds property. See getVisibleBounds()

    + +

    Reads the content_desc property of the UI element

    Returns
    -
    • Rect
    +
    • value of node attribute "content_desc"
    +
    - + -
    +

    - public - - - - - UiObject + public + + + + + UiObject - getChild + getFromParent (UiSelector selector)

    -
    +
    + -
    - -
    - -

    Creates a new UiObject representing a child UI element of the element currently represented - by this UiObject.

    + +

    Creates a new UiObject for a sibling view or a child of the sibling view, + relative to the present UiObject.

    Parameters
    - - +
    selectorfor UI element to matchselector + for a sibling view or children of the sibling view
    Returns
    -
    • a new UiObject representing the matched UI element -
    +
    • a new UiObject representing the matched view
    Throws
    - +
    + @@ -1435,40 +2173,38 @@ From class - + -
    +

    - public - - - - - int + public + + + + + String - getChildCount + getPackageName ()

    -
    +
    + -
    - -
    - -

    Counts the child UI elements immediately under the UI element currently represented by - this UiObject.

    + +

    Reads the view's package property

    Returns
    -
    • the count of child UI elements.
    +
    • true if it is else false
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1480,139 +2216,162 @@ From class - + -
    +

    - public - - - - - String + public + + final + + + UiSelector - getContentDescription + getSelector ()

    -
    +
    + -
    - -
    - -

    Reads the content_desc property of the UI element

    + +

    Debugging helper. A test can dump the properties of a selector as a string + to its logs if needed. getSelector().toString();

    Returns
    -
    • value of node attribute "content_desc"
    -
    -
    -
    Throws
    -
    UiObjectNotFoundException
    - - - -
    UiObjectNotFoundException -
    +
    - + -
    +

    - public - - - - - UiObject + public + + + + + String - getFromParent - (UiSelector selector) + getText + ()

    -
    +
    + -
    - -
    - -

    Creates a new UiObject representing a child UI element from the parent element currently - represented by this object. Essentially this is starting the search from the parent - element and can also be used to find sibling UI elements to the one currently represented - by this UiObject.

    + +

    Reads the text property of the UI element

    -
    Parameters
    +
    Returns
    +
    • text value of the current node represented by this UiObject
    +
    +
    +
    Throws
    - - +
    selectorfor the UI element to matchUiObjectNotFoundException + if no match could be found
    + +
    +
    + + + + +
    +

    + + public + + + + + Rect + + getVisibleBounds + () +

    +
    + +

    Returns the visible bounds of the view. + + If a portion of the view is visible, only the bounds of the visible portion are + reported.

    Returns
    -
    • a new UiObject representing the matched UI element
    +
    • Rect
    - +
    +
    See Also
    + +
    +
    +
    Since
    +
    • Android API Level 17
    +
    - + -
    +

    - public - - - - - String + public + + + + + boolean - getPackageName + isCheckable ()

    -
    +
    + -
    - -
    - -

    Reads the UI element's package property

    + +

    Checks if the UI element's checkable property is currently true.

    Returns
    • true if it is else false
    Throws
    - +
    + @@ -1624,80 +2383,83 @@ From class - + -
    +

    - public - - final - - - UiSelector + public + + + + + boolean - getSelector + isChecked ()

    -
    +
    + -
    - -
    - -

    Debugging helper. A test can dump the properties of a selector as a string - to its logs if needed. getSelector().toString();

    + +

    Check if the UI element's checked property is currently true

    Returns
    - +
    • true if it is else false
    +
    +
    +
    Throws
    +
    UiObjectNotFoundException
    + + + +
    UiObjectNotFoundException +
    - + -
    +

    - public - - - - - String + public + + + + + boolean - getText + isClickable ()

    -
    +
    + -
    - -
    - -

    Reads the text property of the UI element

    + +

    Checks if the UI element's clickable property is currently true.

    Returns
    -
    • text value of the current node represented by this UiObject
    +
    • true if it is else false
    Throws
    - +
    + +
    UiObjectNotFoundException - if no match could be found -
    @@ -1706,93 +2468,81 @@ From class
    - + -
    +

    - public - - - - - Rect + public + + + + + boolean - getVisibleBounds + isEnabled ()

    -
    +
    + -
    - -
    - -

    Returns the visible bounds of the UI element. - If a portion of the UI element is visible, only the bounds of the visible portion are - reported.

    +

    Checks if the UI element's enabled property is currently true.

    Returns
    -
    • Rect
    +
    • true if it is else false
    Throws
    - - - - +
    - UiObjectNotFoundException
    +
    UiObjectNotFoundException
    -
    -
    Since
    -
    • Android API Level 17
    -
    +
    - + -
    +

    - public - - - - + public + + + + boolean - isCheckable + isFocusable ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's checkable property is currently true

    + +

    Check if the UI element's focusable property is currently true.

    Returns
    • true if it is else false
    Throws
    - +
    + @@ -1804,40 +2554,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isChecked + isFocused ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's checked property is currently true

    + +

    Check if the UI element's focused property is currently true

    Returns
    -
    • true if it is else false -
    +
    • true if it is else false
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1849,39 +2597,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isClickable + isLongClickable ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's clickable property is currently true

    + +

    Check if the view's long-clickable property is currently true

    Returns
    • true if it is else false
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1893,39 +2640,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isEnabled + isScrollable ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's enabled property is currently true

    + +

    Check if the view's scrollable property is currently true

    Returns
    • true if it is else false
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1937,39 +2683,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isFocusable + isSelected ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's focusable property is currently true

    + +

    Checks if the UI element's selected property is currently true.

    Returns
    • true if it is else false
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -1981,39 +2726,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isFocused + longClick ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's focused property is currently true

    + +

    Long clicks the center of the visible bounds of the UI element

    Returns
    -
    • true if it is else false
    +
    • true if operation was successful
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -2025,39 +2769,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isLongClickable + longClickBottomRight ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's long-clickable property is currently true

    + +

    Long clicks bottom and right corner of the UI element

    Returns
    -
    • true if it is else false
    +
    • true if operation was successful
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -2069,39 +2812,38 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isScrollable + longClickTopLeft ()

    -
    +
    + -
    - -
    - -

    Check if the UI element's scrollable property is currently true

    + +

    Long clicks on the top and left corner of the UI element

    Returns
    -
    • true if it is else false
    +
    • true if operation was successful
    Throws
    -
    UiObjectNotFoundException
    +
    + @@ -2113,207 +2855,254 @@ From class - + -
    +

    - public - - - - + public + + + + boolean - isSelected - () + performMultiPointerGesture + (PointerCoords... touches)

    -
    -
    - -
    - - - -
    - -

    Check if the UI element's selected property is currently true

    -
    -
    Returns
    -
    • true if it is else false
    -
    + +

    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; +

    -
    Throws
    -
    UiObjectNotFoundException
    +
    Parameters
    +
    - +
    UiObjectNotFoundException - 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.
    - +
    +
    Returns
    +
    • true if all touch events for this gesture are injected successfully, + false otherwise
    +
    +
    +
    Since
    +
    • Android API Level 18
    +
    - + -
    +

    - public - - - - + public + + + + boolean - longClick - () + performTwoPointerGesture + (Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps)

    -
    -
    - -
    - - - -
    - -

    Long clicks the center of the visible bounds of the UI element

    -
    -
    Returns
    -
    • true if operation was successful
    -
    + +

    Generates a two-pointer gesture with arbitrary starting and ending points.

    -
    Throws
    - +
    Parameters
    +
    - + + + + + + + + + + + + +
    UiObjectNotFoundException - 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.
    - +
    +
    Returns
    +
    • true if all touch events for this gesture are injected successfully, + false otherwise
    +
    +
    +
    Since
    +
    • Android API Level 18
    +
    - + -
    +

    - public - - - - + public + + + + boolean - longClickBottomRight - () + pinchIn + (int percent, int steps)

    -
    -
    - -
    - - - -
    - -

    Long clicks bottom and right corner of the UI element

    + +

    Performs a two-pointer gesture, where each pointer moves diagonally + toward the other, from the edges to the center of this UiObject .

    +
    +
    Parameters
    + + + + + + + +
    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.
    +
    Returns
    -
    • true if operation was successful
    +
    • true if all touch events for this gesture are injected successfully, + false otherwise
    - +
    +
    Since
    +
    • Android API Level 18
    +
    - + -
    +

    - public - - - - + public + + + + boolean - longClickTopLeft - () + pinchOut + (int percent, int steps)

    -
    -
    - -
    - - - -
    - -

    Long clicks on the top and left corner of the UI element

    + +

    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.

    +
    +
    Parameters
    + + + + + + + +
    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.
    +
    Returns
    -
    • true if operation was successful
    +
    • true if all touch events for this gesture are injected successfully, + false otherwise
    - +
    +
    Since
    +
    • Android API Level 18
    +
    - + -
    +

    - public - - - - + public + + + + boolean setText (String text)

    -
    +
    + -
    - -
    - +

    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. @@ -2328,7 +3117,7 @@ From class

    Parameters
    - +
    texttext string to set
    @@ -2339,7 +3128,8 @@ From class
    Throws
    - +
    + @@ -2351,41 +3141,44 @@ From class - + -
    +

    - public - - - - + public + + + + boolean swipeDown (int steps)

    -
    +
    + -
    - -
    - -

    Perform the action on the UI element that is represented by this object, Also see - #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), - #scrollForward(). This method will perform the swipe gesture over any - surface. The targeted UI element does not need to have the attribute - scrollable set to true for this operation to be performed.

    + +

    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: +

    Parameters
    UiObjectNotFoundException
    - + @@ -2397,7 +3190,8 @@ From class
    Throws
    -
    stepssteps 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.
    +
    + @@ -2409,41 +3203,44 @@ From class - + -
    +

    - public - - - - + public + + + + boolean swipeLeft (int steps)

    -
    +
    + -
    - -
    - -

    Perform the action on the UI element that is represented by this object. Also see - #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), - #scrollForward(). This method will perform the swipe gesture over any - surface. The targeted UI element does not need to have the attribute - scrollable set to true for this operation to be performed.

    + +

    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: +

    Parameters
    UiObjectNotFoundException
    - + @@ -2455,7 +3252,8 @@ From class
    Throws
    -
    stepssteps 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.
    +
    + @@ -2467,41 +3265,44 @@ From class - + -
    +

    - public - - - - + public + + + + boolean swipeRight (int steps)

    -
    +
    + -
    - -
    - -

    Perform the action on the UI element that is represented by this object. Also see - #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), - #scrollForward(). This method will perform the swipe gesture over any - surface. The targeted UI element does not need to have the attribute - scrollable set to true for this operation to be performed.

    + +

    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: +

    Parameters
    UiObjectNotFoundException
    - + @@ -2513,7 +3314,8 @@ From class
    Throws
    -
    stepssteps 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.
    +
    + @@ -2525,39 +3327,42 @@ From class - + -
    +

    - public - - - - + public + + + + boolean swipeUp (int steps)

    -
    +
    + -
    - -
    - -

    Perform the action on the UI element that is represented by this UiObject. Also see - #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), - #scrollForward().

    + +

    Performs the swipe up action on the UiObject. + See also: +

    Parameters
    UiObjectNotFoundException
    - + @@ -2569,7 +3374,8 @@ From class
    Throws
    -
    stepssteps 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.
    +
    + @@ -2581,86 +3387,81 @@ From class - + -
    +

    - public - - - - + public + + + + boolean waitForExists (long timeout)

    -
    +
    + -
    - -
    - -

    Waits a specified length of time for a UI element to become visible. - This method waits until the UI element becomes visible on the display, or +

    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.

    Parameters
    UiObjectNotFoundException
    - +
    timeouttimeout the amount of time to wait (in milliseconds)
    Returns
    -
    • true if the UI element is displayed, else false if timeout elapsed while waiting -
    +
    • true if the view is displayed, else false if timeout elapsed while waiting
    - + -
    +

    - public - - - - + public + + + + boolean waitUntilGone (long timeout)

    -
    +
    + -
    - -
    - -

    Waits a specified length of time for a UI element to become undetectable. - This method waits until a UI element is no longer matchable, or until the +

    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 UI element becomes undetectable when the UiSelector of the object is + 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. @@ -2670,7 +3471,7 @@ From class

    Parameters
    - +
    timeouttimeout time to wait (in milliseconds)
    @@ -2678,10 +3479,65 @@ From class
    Returns
    • true if the element is gone before timeout elapsed, else false if timeout elapsed - but a matching element is still found. -
    + but a matching element is still found.
    + + + + + + +

    Protected Methods

    + + + + + +
    +

    + + protected + + + + + AccessibilityNodeInfo + + findAccessibilityNodeInfo + (long timeout) +

    +
    +
    + + + +
    +
    + +

    Finds a matching UI element in the accessibility hierarchy, by + using the selector for this UiObject.

    +
    +
    Parameters
    + + + + +
    timeout + in milliseconds
    +
    +
    +
    Returns
    +
    • AccessibilityNodeInfo if found else null
    +
    + +
    + + + + + + diff --git a/docs/html/tools/help/uiautomator/UiObjectNotFoundException.jd b/docs/html/tools/help/uiautomator/UiObjectNotFoundException.jd index 02c607d75c29..b41cfe5590d7 100644 --- a/docs/html/tools/help/uiautomator/UiObjectNotFoundException.jd +++ b/docs/html/tools/help/uiautomator/UiObjectNotFoundException.jd @@ -9,29 +9,6 @@ parent.link=index.html to any UI element displayed.

    - - - - - - - - - - - - - - - - - - - - -
    - -

    Summary

    @@ -627,4 +604,3 @@ From class

    -
    diff --git a/docs/html/tools/help/uiautomator/UiScrollable.jd b/docs/html/tools/help/uiautomator/UiScrollable.jd index 33566a2ecdfa..7405f3b6d8e4 100644 --- a/docs/html/tools/help/uiautomator/UiScrollable.jd +++ b/docs/html/tools/help/uiautomator/UiScrollable.jd @@ -5,9 +5,10 @@ parent.link=index.html -

    UiScrollable is a UiCollection and provides support for searching for items in a - scrollable user interface (UI) elements. This class can be used with horizontally or vertically scrollable controls.. -

    +

    A UiCollection +that supports searching for items in scrollable layout elements. This class can +be used with horizontally or vertically scrollable controls.

    +

    Summary

    @@ -24,29 +25,88 @@ parent.link=index.html + + + + +
    + [Expand] +
    Inherited Constants
    -
    + From class +com.android.uiautomator.core.UiObject +
    + + +
    +
    @@ -61,22 +121,21 @@ parent.link=index.html - + - - - - - - - + + + + + + + - - UiScrollable(UiSelector container) - -
    UiScrollable is a UiCollection and as such requires a UiSelector to - identify the container UI element of the scrollable collection.
    - + + UiScrollable(UiSelector container) + +
    Constructor.
    + @@ -93,1255 +152,1446 @@ parent.link=index.html - + - - - - - - - boolean + + + + + + + boolean - - flingBackward() - - - + + flingBackward() + +
    Performs a backwards fling action with the default number of fling + steps (5).
    + - + - - - - - - - boolean + + + + + + + boolean - - flingForward() - -
    A convenience version of scrollForward(int), performs a fling
    - + + flingForward() + +
    Performs a forward fling with the default number of fling steps (5).
    + - + - - - - - - - boolean + + + + + + + boolean - - flingToBeginning(int maxSwipes) - - - + + flingToBeginning(int maxSwipes) + +
    Performs a fling gesture to reach the beginning of a scrollable layout element.
    + - + - - - - - - - boolean + + + + + + + boolean - - flingToEnd(int maxSwipes) - - - + + flingToEnd(int maxSwipes) + +
    Performs a fling gesture to reach the end of a scrollable layout element.
    + - + - - - - - - - UiObject + + + + + + + UiObject - - getChildByDescription(UiSelector childPattern, String text, boolean allowScrollSearch) - - - + + getChildByDescription(UiSelector childPattern, String text, boolean allowScrollSearch) + +
    Searches for a child element in the present scrollable container.
    + - + - - - - - - - UiObject + + + + + + + UiObject - - getChildByDescription(UiSelector childPattern, String text) - -
    Searches for child UI element within the constraints of this UiScrollable UiSelector - container.
    - + + getChildByDescription(UiSelector childPattern, String text) + +
    Searches for a child element in the present scrollable container.
    + - + - - - - - - - UiObject + + + + + + + UiObject - - getChildByInstance(UiSelector childPattern, int instance) - -
    Searches for child UI element within the constraints of this UiScrollable UiSelector - selector.
    - + + getChildByInstance(UiSelector childPattern, int instance) + +
    Searches for a child element in the present scrollable container that + matches the selector you provided.
    + - + - - - - - - - UiObject + + + + + + + UiObject - - getChildByText(UiSelector childPattern, String text, boolean allowScrollSearch) - - - + + getChildByText(UiSelector childPattern, String text, boolean allowScrollSearch) + +
    Searches for a child element in the present scrollable container.
    + - + - - - - - - - UiObject + + + + + + + UiObject - - getChildByText(UiSelector childPattern, String text) - -
    Searches for child UI element within the constraints of this UiScrollable UiSelector + + getChildByText(UiSelector childPattern, String text) + +
    Searches for a child element in the present scrollable container.
    - + - + - - - - - - - int - - - getMaxSearchSwipes() - -
    #getChildByDescription(String, boolean) and #getChildByText(String, boolean) - use an arguments that specifies if scrolling is allowed while searching for the UI element.
    - - + - - - - - - - - - double - - - getSwipeDeadZonePercentage() - -
    Returns the percentage of a widget's size that's considered as a no touch zone when swiping.
    - - - - - - - - - - - boolean + + int
    - - scrollBackward(int steps) - -
    Perform a scroll backward.
    - - + + getMaxSearchSwipes() +
    Gets the maximum number of scrolls allowed when performing a + scroll action in search of a child element.
    - - - - - - - - - boolean - - - scrollBackward() - - - - + - - - - - - - boolean - - - scrollDescriptionIntoView(String text) - -
    Performs a swipe Up on the UI element until the requested content-description - is visible or until swipe attempts have been exhausted.
    - - + - - - - - - - - - boolean - - - scrollForward() - -
    A convenience version of scrollForward(int), performs a regular scroll
    - - - - - - - - - - - boolean + + double
    - - scrollForward(int steps) - -
    Perform a scroll forward.
    - - + + getSwipeDeadZonePercentage() +
    Returns the percentage of a widget's size that's considered as a no-touch + zone when swiping.
    - - - - - - - - - boolean - - - scrollIntoView(UiSelector selector) - -
    Perform a scroll search for a UI element matching the UiSelector selector argument.
    - - + - - - - - - - boolean - - - scrollTextIntoView(String text) - -
    Performs a swipe up on the UI element until the requested text is visible - or until swipe attempts have been exhausted.
    - - + - - - - - - - - - boolean - - - scrollToBeginning(int maxSwipes) - - - - - - - - - - - - - boolean + + boolean - - scrollToBeginning(int maxSwipes, int steps) - -
    Scrolls to the beginning of a scrollable UI element.
    - - + + scrollBackward(int steps) +
    Performs a backward scroll.
    - - - - - - - - - boolean - - - scrollToEnd(int maxSwipes, int steps) - -
    Scrolls to the end of a scrollable UI element.
    - - + - - - - - - - boolean - - - scrollToEnd(int maxSwipes) - -
    See {@link UiScrollable#scrollToEnd(int, int)
    - - + - - - - - - - - - void + + + + boolean - - setAsHorizontalList() - -
    Set the direction of swipes when performing scroll search -
    - + + scrollBackward() + +
    Performs a backward scroll with the default number of scroll steps (55).
    + - + - - - - - - - void + + + + + + + boolean - - setAsVerticalList() - -
    Set the direction of swipes when performing scroll search -
    - + + scrollDescriptionIntoView(String text) + +
    Performs a forward scroll action on the scrollable layout element until + the content-description is found, or until swipe attempts have been exhausted.
    + - + - - - - - - - void + + + + + + + boolean - - setMaxSearchSwipes(int swipes) - -
    #getChildByDescription(String, boolean) and #getChildByText(String, boolean) - use an arguments that specifies if scrolling is allowed while searching for the UI element.
    - + + scrollForward() + +
    Performs a forward scroll with the default number of scroll steps (55).
    + - + - - - - - - - void + + + + + + + boolean - - setSwipeDeadZonePercentage(double swipeDeadZonePercentage) - -
    Sets the percentage of a widget's size that's considered as a no touch zone when swiping.
    - + + scrollForward(int steps) + +
    Performs a forward scroll.
    + - + + + boolean + + + scrollIntoView(UiSelector selector) +
    Perform a scroll forward action to move through the scrollable layout + element until a visible item that matches the selector is found.
    - - + - - + - - + -
    - -
    - [Expand] -
    Inherited Methods
    - -From class - com.android.uiautomator.core.UiCollection +
    -
    - - -
    -
    - -From class + boolean + + scrollToBeginning(int maxSwipes, int steps) - com.android.uiautomator.core.UiObject +
    Scrolls to the beginning of a scrollable layout element.
    + +
    - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    - - - - - - void + + + + + + + boolean - clearTextField() - -
    Clears the existing text contents in an editable field.
    - +
    + scrollToEnd(int maxSwipes, int steps) + +
    Scrolls to the end of a scrollable layout element.
    +
    - - - - - - boolean - - click() - + + + + + + + boolean + + scrollToEnd(int maxSwipes) + +
    Scrolls to the end of a scrollable layout element.
    + +
    + + + + + + UiScrollable + + setAsHorizontalList() + +
    Set the direction of swipes to be horizontal when performing scroll actions.
    + +
    + + + + + + UiScrollable + + setAsVerticalList() + +
    Set the direction of swipes to be vertical when performing scroll actions.
    + +
    + + + + + + UiScrollable + + setMaxSearchSwipes(int swipes) + +
    Sets the maximum number of scrolls allowed when performing a + scroll action in search of a child element.
    + +
    + + + + + + UiScrollable + + setSwipeDeadZonePercentage(double swipeDeadZonePercentage) + +
    Sets the percentage of a widget's size that's considered as no-touch + zone when swiping.
    + +
    + + + + + + + + + + + + + + + + +
    Protected Methods
    + + + + + + boolean + + exists(UiSelector selector) + +
    Used privately when performing swipe searches to decide if an element has become + visible or not.
    + +
    + + + + + + + + + + + + + + + +
    + [Expand] +
    Inherited Methods
    + +From class + + com.android.uiautomator.core.UiCollection + +
    + + +
    +
    + +From class + + com.android.uiautomator.core.UiObject + +
    + +