Android Wireless test-uiautomator uiscrollable API Introduction Three

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.