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