Android Wireless test-uiautomator Uiselector API Introduction Seven

Source: Internet
Author: User

Object Search-Indexes and instances

First, index and instance description:

1) Index: number in the same level, number of the component in the sibling class, index starting from 0

2) Instance: number of the same class of components in the same layout, instance starting from 0

Second, index and instance property anchored object

return value Api Describe
Uiselector Index (int index) Index
Uiselector instance (int instance) Instance

Iii. Examples of API applications

 PackageCom.testuiselector;ImportAndroid.view.View;ImportCom.android.uiautomator.core.UiDevice;ImportCom.android.uiautomator.core.UiObject;Importcom.android.uiautomator.core.UiObjectNotFoundException;ImportCom.android.uiautomator.core.UiSelector;Importcom.android.uiautomator.testrunner.UiAutomatorTestCase; Public classDemo1extendsUiautomatortestcase {/**     * @paramargs*/     Public Static voidMain (string[] args) {//TODO auto-generated Method StubString jarname, TestClass, testname, Androidid; Jarname= "Demo1"; TestClass= "Com.testuiselector.Demo1"; TestName= "Testpackage"; Androidid= "1"; NewUiautomatorhelper (Jarname, TestClass, testname, Androidid); }         Public voidTestClass ()throwsuiobjectnotfoundexception{uidevice.getinstance (). Presshome (); Sleep (1000); //Exact MatchUiselector l1=NewUiselector (). ClassName ("Android.view.View"). Instance (3); UiObject Clock1=NewUiObject (L1);        Clock1.click (); Sleep (1000);        Uidevice.getinstance (). Pressback (); Sleep (1000); //regular MatchUiselector l2=NewUiselector (). Classnamematches (". *view"). Instance (4); UiObject Clock2=NewUiObject (L2);        Clock2.click (); Sleep (1000);        Uidevice.getinstance (). Pressback (); Sleep (1000); //Class.getname ()Uiselector l3=NewUiselector (). ClassName (View.class. GetName ()). Instance (3); UiObject Clock3=NewUiObject (L3);        Clock3.click (); Sleep (1000);            Uidevice.getinstance (). Pressback (); }         Public voidTestpackage ()throwsuiobjectnotfoundexception{uidevice.getinstance (). Presshome (); Sleep (1000); Uiselector DL1=NewUiselector (). PackageName ("Com.android.deskclock"); UiObject Deskclock1=NewUiObject (DL1);        Deskclock1.click (); Sleep (1000);        Uidevice.getinstance (). Pressback (); Sleep (1000); Uiselector DL2=NewUiselector (). Packagenamematches (". *deskclock"); UiObject Deskclock2=NewUiObject (DL2);                    Deskclock2.click (); }}
Demo1.java

Android Wireless test-uiautomator Uiselector API introduction of seven

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.