page.title=UiObject parent.title=uiautomator parent.link=index.html @jd:body <style> h4.jd-details-title {background-color: #DEE8F1;} </style> <p>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 <code><a href="UiSelector.html">UiSelector</a></code> 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. </p> <div class="jd-descr"> <h2>Summary</h2> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <table id="pubctors" class="jd-sumtable"><tr><th colspan="12">Public Constructors</th></tr> <tr class="api" > <td class="jd-typecol"> </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#UiObject(com.android.uiautomator.core.UiSelector)">UiObject</a></span>(<a href="UiSelector.html">UiSelector</a> selector) <div class="jd-descrdiv">Constructs a UiObject to represent a specific UI element matched by the specified <code><a href="UiSelector.html">UiSelector</a></code> selector properties.</div> </td></tr> </table> <!-- ========== METHOD SUMMARY =========== --> <table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr> <tr class="api" > <td class="jd-typecol"> void </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#clearTextField()">clearTextField</a></span>() <div class="jd-descrdiv">Clears the existing text contents in an editable field.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#click()">click</a></span>() <div class="jd-descrdiv">Performs a click at the center of the visible bounds of the UI element represented by this UiObject.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#clickAndWaitForNewWindow(long)">clickAndWaitForNewWindow</a></span>(long timeout) <div class="jd-descrdiv">Performs a click at the center of the visible bounds of the UI element represented by this UiObject and waits for window transitions.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#clickAndWaitForNewWindow()">clickAndWaitForNewWindow</a></span>() <div class="jd-descrdiv">See <code><a href="#clickAndWaitForNewWindow(long)">clickAndWaitForNewWindow(long)</a></code> This method is intended to reliably wait for window transitions that would typically take longer than the usual default timeouts.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#clickBottomRight()">clickBottomRight</a></span>() <div class="jd-descrdiv">Clicks the bottom and right corner of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#clickTopLeft()">clickTopLeft</a></span>() <div class="jd-descrdiv">Clicks the top and left corner of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#exists()">exists</a></span>() <div class="jd-descrdiv">Check if UI element exists.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> Rect </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getBounds()">getBounds</a></span>() <div class="jd-descrdiv">Returns the UI element's <code>bounds</code> property.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> <a href="UiObject.html">UiObject</a> </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getChild(com.android.uiautomator.core.UiSelector)">getChild</a></span>(<a href="UiSelector.html">UiSelector</a> selector) <div class="jd-descrdiv">Creates a new UiObject representing a child UI element of the element currently represented by this UiObject.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> int </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getChildCount()">getChildCount</a></span>() <div class="jd-descrdiv">Counts the child UI elements immediately under the UI element currently represented by this UiObject.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> String </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getContentDescription()">getContentDescription</a></span>() <div class="jd-descrdiv">Reads the <code>content_desc</code> property of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> <a href="UiObject.html">UiObject</a> </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getFromParent(com.android.uiautomator.core.UiSelector)">getFromParent</a></span>(<a href="UiSelector.html">UiSelector</a> selector) <div class="jd-descrdiv">Creates a new UiObject representing a child UI element from the parent element currently represented by this object.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> String </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getPackageName()">getPackageName</a></span>() <div class="jd-descrdiv">Reads the UI element's <code>package</code> property</div> </td></tr> <tr class="api" > <td class="jd-typecol"> final <a href="UiSelector.html">UiSelector</a> </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getSelector()">getSelector</a></span>() <div class="jd-descrdiv">Debugging helper.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> String </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getText()">getText</a></span>() <div class="jd-descrdiv">Reads the <code>text</code> property of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> Rect </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#getVisibleBounds()">getVisibleBounds</a></span>() <div class="jd-descrdiv">Returns the visible bounds of the UI element.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isCheckable()">isCheckable</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>checkable</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isChecked()">isChecked</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>checked</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isClickable()">isClickable</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>clickable</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isEnabled()">isEnabled</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>enabled</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isFocusable()">isFocusable</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>focusable</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isFocused()">isFocused</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>focused</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isLongClickable()">isLongClickable</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>long-clickable</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isScrollable()">isScrollable</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>scrollable</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#isSelected()">isSelected</a></span>() <div class="jd-descrdiv">Check if the UI element's <code>selected</code> property is currently true</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#longClick()">longClick</a></span>() <div class="jd-descrdiv">Long clicks the center of the visible bounds of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#longClickBottomRight()">longClickBottomRight</a></span>() <div class="jd-descrdiv">Long clicks bottom and right corner of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#longClickTopLeft()">longClickTopLeft</a></span>() <div class="jd-descrdiv">Long clicks on the top and left corner of the UI element</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#setText(java.lang.String)">setText</a></span>(String text) <div class="jd-descrdiv">Sets the text in an editable field, after clearing the field's content.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#swipeDown(int)">swipeDown</a></span>(int steps) <div class="jd-descrdiv">Perform the action on the UI element that is represented by this object, Also see #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), #scrollForward().</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#swipeLeft(int)">swipeLeft</a></span>(int steps) <div class="jd-descrdiv">Perform the action on the UI element that is represented by this object.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#swipeRight(int)">swipeRight</a></span>(int steps) <div class="jd-descrdiv">Perform the action on the UI element that is represented by this object.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#swipeUp(int)">swipeUp</a></span>(int steps) <div class="jd-descrdiv">Perform the action on the UI element that is represented by this UiObject.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#waitForExists(long)">waitForExists</a></span>(long timeout) <div class="jd-descrdiv">Waits a specified length of time for a UI element to become visible.</div> </td></tr> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad"><a href="#waitUntilGone(long)">waitUntilGone</a></span>(long timeout) <div class="jd-descrdiv">Waits a specified length of time for a UI element to become undetectable.</div> </td></tr> </table> <!-- ========== METHOD SUMMARY =========== --> <table id="inhmethods" class="jd-sumtable"><tr><th> <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a> <div style="clear:left;">Inherited Methods</div></th></tr> <tr class="api apilevel-" > <td colspan="12"> <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed" ><img id="inherited-methods-java.lang.Object-trigger" src="../../../../../assets/images/triangle-closed.png" class="jd-expando-trigger-img" /></a> From class java.lang.Object <div id="inherited-methods-java.lang.Object"> <div id="inherited-methods-java.lang.Object-list" class="jd-inheritedlinks"> </div> <div id="inherited-methods-java.lang.Object-summary" style="display: none;"> <table class="jd-sumtable-expando"> <tr class="api" > <td class="jd-typecol"> boolean </td> <td class="jd-linkcol" width="100%"> <span class="sympad">equals</span>(Object arg0) </td></tr> <tr class="api" > <td class="jd-typecol"> final Class<?> </td> <td class="jd-linkcol" width="100%"> <span class="sympad">getClass</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> int </td> <td class="jd-linkcol" width="100%"> <span class="sympad">hashCode</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> final void </td> <td class="jd-linkcol" width="100%"> <span class="sympad">notify</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> final void </td> <td class="jd-linkcol" width="100%"> <span class="sympad">notifyAll</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> String </td> <td class="jd-linkcol" width="100%"> <span class="sympad">toString</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> final void </td> <td class="jd-linkcol" width="100%"> <span class="sympad">wait</span>() </td></tr> <tr class="api" > <td class="jd-typecol"> final void </td> <td class="jd-linkcol" width="100%"> <span class="sympad">wait</span>(long arg0, int arg1) </td></tr> <tr class="api" > <td class="jd-typecol"> final void </td> <td class="jd-linkcol" width="100%"> <span class="sympad">wait</span>(long arg0) </td></tr> </table> </div> </div> </td></tr> </table> </div><!-- jd-descr (summary) --> <!-- Details --> <!-- XML Attributes --> <!-- Enum Values --> <!-- Constants --> <!-- Fields --> <!-- Public ctors --> <!-- ========= CONSTRUCTOR DETAIL ======== --> <h2>Public Constructors</h2> <a id="UiObject(com.android.uiautomator.core.UiSelector)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public </span> <span class="sympad">UiObject</span> <span class="normal">(<a href="UiSelector.html">UiSelector</a> selector)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Constructs a UiObject to represent a specific UI element matched by the specified <code><a href="UiSelector.html">UiSelector</a></code> selector properties.</p></div> </div> </div> <!-- ========= CONSTRUCTOR DETAIL ======== --> <!-- Protected ctors --> <!-- ========= METHOD DETAIL ======== --> <!-- Public methdos --> <h2>Public Methods</h2> <a id="clearTextField()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public void </span> <span class="sympad">clearTextField</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Clears the existing text contents in an editable field. The <code><a href="UiSelector.html">UiSelector</a></code> 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.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="click()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">click</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Performs a click at the center of the visible bounds of the UI element represented by this UiObject.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true id successful else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="clickAndWaitForNewWindow(long)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">clickAndWaitForNewWindow</span> <span class="normal">(long timeout)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 <code><a href="#click()">click()</a></code> only in that this method waits for a a new window transition as a result of the click. Some examples of a window transition: <li>launching a new activity</li> <li>bringing up a pop-up menu</li> <li>bringing up a dialog</li></p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>timeout</th> <td>timeout before giving up on waiting for a new window</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if the event was triggered, else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="clickAndWaitForNewWindow()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">clickAndWaitForNewWindow</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>See <code><a href="#clickAndWaitForNewWindow(long)">clickAndWaitForNewWindow(long)</a></code> This method is intended to reliably wait for window transitions that would typically take longer than the usual default timeouts.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if the event was triggered, else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="clickBottomRight()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">clickBottomRight</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Clicks the bottom and right corner of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true on success</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th>Exception</td> <td></td> </tr> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="clickTopLeft()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">clickTopLeft</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Clicks the top and left corner of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true on success</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th>Exception</td> <td></td> </tr> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="exists()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">exists</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if UI element exists. This methods performs a <code><a href="#waitForExists(long)">waitForExists(long)</a></code> 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 <code><a href="#waitForExists(long)">waitForExists(long)</a></code>.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if the UI element represented by this UiObject does exist </li></ul> </div> </div> </div> <a id="getBounds()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public Rect </span> <span class="sympad">getBounds</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Returns the UI element's <code>bounds</code> property. See <code><a href="#getVisibleBounds()">getVisibleBounds()</a></code></p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>Rect</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getChild(com.android.uiautomator.core.UiSelector)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public <a href="UiObject.html">UiObject</a> </span> <span class="sympad">getChild</span> <span class="normal">(<a href="UiSelector.html">UiSelector</a> selector)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Creates a new UiObject representing a child UI element of the element currently represented by this UiObject.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>selector</th> <td>for UI element to match</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>a new UiObject representing the matched UI element </li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getChildCount()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public int </span> <span class="sympad">getChildCount</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Counts the child UI elements immediately under the UI element currently represented by this UiObject.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>the count of child UI elements.</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getContentDescription()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public String </span> <span class="sympad">getContentDescription</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Reads the <code>content_desc</code> property of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>value of node attribute "content_desc"</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getFromParent(com.android.uiautomator.core.UiSelector)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public <a href="UiObject.html">UiObject</a> </span> <span class="sympad">getFromParent</span> <span class="normal">(<a href="UiSelector.html">UiSelector</a> selector)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>selector</th> <td>for the UI element to match</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>a new UiObject representing the matched UI element</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getPackageName()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public String </span> <span class="sympad">getPackageName</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Reads the UI element's <code>package</code> property</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="getSelector()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public final <a href="UiSelector.html">UiSelector</a> </span> <span class="sympad">getSelector</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Debugging helper. A test can dump the properties of a selector as a string to its logs if needed. <code>getSelector().toString();</code></p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li><code><a href="UiSelector.html">UiSelector</a></code> </li></ul> </div> </div> </div> <a id="getText()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public String </span> <span class="sympad">getText</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Reads the <code>text</code> property of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>text value of the current node represented by this UiObject</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td>if no match could be found </td> </tr> </table> </div> </div> </div> <a id="getVisibleBounds()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public Rect </span> <span class="sympad">getVisibleBounds</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>Rect</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th></td> <td>UiObjectNotFoundException</td> </tr> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Since</h5> <ul class="nolist"><li>Android API Level 17</li></ul> </div> </div> </div> <a id="isCheckable()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isCheckable</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>checkable</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isChecked()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isChecked</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>checked</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false </li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isClickable()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isClickable</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>clickable</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isEnabled()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isEnabled</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>enabled</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isFocusable()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isFocusable</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>focusable</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isFocused()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isFocused</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>focused</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isLongClickable()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isLongClickable</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>long-clickable</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isScrollable()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isScrollable</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>scrollable</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="isSelected()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">isSelected</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Check if the UI element's <code>selected</code> property is currently true</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if it is else false</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="longClick()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">longClick</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Long clicks the center of the visible bounds of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if operation was successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="longClickBottomRight()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">longClickBottomRight</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Long clicks bottom and right corner of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if operation was successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="longClickTopLeft()"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">longClickTopLeft</span> <span class="normal">()</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Long clicks on the top and left corner of the UI element</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if operation was successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="setText(java.lang.String)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">setText</span> <span class="normal">(String text)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Sets the text in an editable field, after clearing the field's content. The <code><a href="UiSelector.html">UiSelector</a></code> selector of this object must reference a UI element that is editable. When you call this method, the method first simulates a <code><a href="#click()">click()</a></code> on editable field to set focus. The method then clears the field's contents and injects your specified text into the field. If you want to capture the original contents of the field, call <code><a href="#getText()">getText()</a></code> first. You can then modify the text and use this method to update the field.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>text</th> <td>string to set</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if operation is successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="swipeDown(int)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">swipeDown</span> <span class="normal">(int steps)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 <code>scrollable</code> set to <code>true</code> for this operation to be performed.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>steps</th> <td>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.</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="swipeLeft(int)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">swipeLeft</span> <span class="normal">(int steps)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 <code>scrollable</code> set to <code>true</code> for this operation to be performed.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>steps</th> <td>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.</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="swipeRight(int)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">swipeRight</span> <span class="normal">(int steps)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 <code>scrollable</code> set to <code>true</code> for this operation to be performed.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>steps</th> <td>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.</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="swipeUp(int)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">swipeUp</span> <span class="normal">(int steps)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>Perform the action on the UI element that is represented by this UiObject. Also see #scrollToBeginning(int), #scrollToEnd(int), #scrollBackward(), #scrollForward().</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>steps</th> <td>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.</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true of successful</li></ul> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Throws</h5> <table class="jd-tagtable"> <tr> <th><a href="UiObjectNotFoundException.html">UiObjectNotFoundException</a></td> <td></td> </tr> </table> </div> </div> </div> <a id="waitForExists(long)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">waitForExists</span> <span class="normal">(long timeout)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 until the timeout has elapsed. You can use this method in situations where the content that you want to select is not immediately displayed.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>timeout</th> <td>the amount of time to wait (in milliseconds)</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if the UI element is displayed, else false if timeout elapsed while waiting </li></ul> </div> </div> </div> <a id="waitUntilGone(long)"></a> <div class="jd-details api "> <h4 class="jd-details-title"> <span class="normal"> public boolean </span> <span class="sympad">waitUntilGone</span> <span class="normal">(long timeout)</span> </h4> <div class="api-level"> <div> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>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 timeout has elapsed. A UI element becomes undetectable when the <code><a href="UiSelector.html">UiSelector</a></code> 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.</p></div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Parameters</h5> <table class="jd-tagtable"> <tr> <th>timeout</th> <td>time to wait (in milliseconds)</td> </tr> </table> </div> <div class="jd-tagdata"> <h5 class="jd-tagtitle">Returns</h5> <ul class="nolist"><li>true if the element is gone before timeout elapsed, else false if timeout elapsed but a matching element is still found. </li></ul> </div> </div> </div>