Android Wireless test-uiautomator UiObject API Introduction II

Source: Internet
Author: User

Click and Long Press

I. Component area position relationship

Rect object represents a rectangular region [left,top] [Right,bottom]

Second, click and long Press API

return value Api Describe
Boolean Click () Click Object
Boolean Clickandwaitfornewwindow (lang timeout) Click on object, wait for new window to appear, parameter is wait for extra long time
Boolean Clickandwaitfornewwindow () Click on the object and wait for the new window to appear
Boolean Clickbottomright () Click the lower-right corner of the object
Boolean Clicktopleft () Click the upper-left corner of the object
Boolean Longclick () Long press the object, the CEO presses the action
Boolean Longclickbottomright () Long press the bottom right corner of the object
Boolean Longclicktopleft () Long press the upper-left corner of the object

Iii. Examples of API applications

 PackageCom.test.uiobject;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 classDemoextendsUiautomatortestcase {/**     * @paramargs*/     Public Static voidMain (string[] args) {String jarname,testclass,testname,androidid; Jarname= "Demo"; TestClass= "Com.test.uiobject.Demo"; TestName= "Testlongclick"; Androidid= "1"; NewUiautomatorhelper (Jarname,testclass,testname,androidid); }         Public voidTestclick ()throwsuiobjectnotfoundexception{uidevice.getinstance (). Presshome (); Sleep (1000); //Click ()UiObject clock=NewUiObject (NewUiselector (). ResourceId ("Com.android.deskclock:id/analog_appwidget"));        Clock.click (); Sleep (2000);        Uidevice.getinstance (). Pressback (); Sleep (2000); //Clickandwaitfornewwindow ()Clock.clickandwaitfornewwindow ();        Uidevice.getinstance (). Pressback (); Sleep (2000); //Clickandwaitfornewwindow (Timeout)Clock.clickandwaitfornewwindow (5000);        Uidevice.getinstance (). Pressback (); Sleep (2000); //clickbottomright ()clock.clickbottomright (); Sleep (2000);        Uidevice.getinstance (). Pressback (); Sleep (2000); //Clicktopleft ()Clock.clicktopleft (); Sleep (2000);            Uidevice.getinstance (). Pressback (); }         Public voidTestlongclick ()throwsuiobjectnotfoundexception{uidevice.getinstance (). Presshome (); Sleep (2000); //Longclick ()UiObject people=NewUiObject (NewUiselector (). Text ("People"));        People.longclick (); Sleep (2000); //longclickbottomright ()people.longclickbottomright (); Sleep (2000); //Longclicktopleft ()People.longclicktopleft (); }}
Demo.java

Android Wireless test-uiautomator UiObject API Introduction II

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.