Get list child elements
First, the relevant API introduction
return value |
Api |
Describe |
UiObject |
Getchildbydescription (Uiselector childpattern, String text, Boolean allowscrollsearch) |
Whether to allow scrolling viewing gets the Uiselector conditional elements collection and then finds the object as a text description condition |
UiObject |
Getchildbydescription (Uiselector childpattern, String text) |
Default scrolling gets a collection of uiselector conditional elements and then finds the object as a text description condition |
UiObject |
Getchildbyinstance (uiselector childpattern, int instance) |
Gets a subset of the uiselector conditions, and then filters the desired elements by instance from the sub-set (without scrolling) |
UiObject |
Getchildbytext (Uiselector childpattern, String text, Boolean allowscrollsearch) |
Whether to allow scrolling viewing gets the collection of uiselector conditional elements and finds the object as a text condition |
UiObject |
Getchildbytext (Uiselector childpattern, String text) |
Default scrolling gets a collection of uiselector conditional elements and finds objects with text conditions |
Ii. Examples of API applications
PackageCom.testuiselector;ImportCom.android.uiautomator.core.UiDevice;ImportCom.android.uiautomator.core.UiObject;Importcom.android.uiautomator.core.UiObjectNotFoundException;Importcom.android.uiautomator.core.UiScrollable;ImportCom.android.uiautomator.core.UiSelector;Importcom.android.uiautomator.testrunner.UiAutomatorTestCase; Public classDemoextendsUiautomatortestcase {/** * @paramargs*/ Public Static voidMain (string[] args) {String jarname, TestClass, testname, Androidid; Jarname= "Demo2"; TestClass= "Com.testuiselector.Demo"; TestName= "Testscrollgetchild"; Androidid= "1"; NewUiautomatorhelper (Jarname, TestClass, testname, Androidid); } Public voidTestscrollgetchild ()throwsuiobjectnotfoundexception{uidevice.getinstance (). Presshome (); Sleep (1000); UiObject people=NewUiObject (NewUiselector (). Text ("People")); People.clickandwaitfornewwindow (); uiscrollable Scroll=NewUiscrollable (NewUiselector (). ClassName ("Android.widget.ListView")); //specifies that a child element can be scrolled to find the phone information on any page successfullyUiObject H=scroll.getchildbytext (NewUiselector (). ClassName ("Android.widget.TextView"), "H",true); H.click (); //Specifies that you cannot scroll to find child elements, and if the phone information you are looking for is not on the first page, an errorUiObject J=scroll.getchildbytext (NewUiselector (). ClassName ("Android.widget.TextView"), "J",false); J.click (); //getchildbyinstance, can not scroll, so find the non-first page of the phone information will be errorUiObject Someone=scroll.getchildbyinstance (NewUiselector (). ClassName ("Android.widget.TextView"), 20); Someone.click (); }}
Demo.java
Ii. examples of relevant API applications
Android Wireless test-uiautomator uiscrollable API Introduction Three