"Uiautomator" Uidevice

Source: Internet
Author: User

Uidevice

Class Description:

Uidevice is used to access state information about the device, which you can use to simulate user behavior on the device, such as the D-pad key operation or the Home key and the menu key

Method Description:

Press to use

Click (int x,int y): Boolean–uidevice

Click the user-specified coordinates

Pressback (): Boolean-uidevice

Analog Back Key

Pressdelete (): Boolean-uidevice

Analog Delete key

Pressdpadcenter (): Boolean-uidevice

Analog Center Key

Pressdpaddown (): Boolean-uidevice

Analog Down key

Pressdpadleft (): Boolean-uidevice

Analog left button

Pressdpadright (): Boolean-uidevice

Simulate right-click

Pressdpadup (): Boolean-uidevice

Simulate up key

Pressenter (): Boolean-uidevice

Impersonate the ENTER key

Presshome (): Boolean-uidevice

Analog Home key

Presskeycode (int keycode): Boolean-uidevice

Using KeyCode to simulate keyboard keys

Presskeycode (int keycode,int metaState): Boolean-uidevice

Analog key Code, metastate=shift=1

Pressmenu (): Boolean-uidevice

Menu key

Pressrecentapps (): Boolean-uidevice

Press the recent application button

Presssearch (): Boolean-uidevice

Simulation Search Key

Drag and slide

Drag (int startx,int starty,int endx,int endy,int steps): Boolean–uidevice

Dragging a coordinate to another coordinate

Swipe (point[] segments,int segmentsteps): Boolean-uidevice

Slide in dot matrix, 5ms for one step

Segments:point[] Lattice column, can be multiple points; Segmentsteps: Sliding step

Swipe (int startx,int starty,int endx,int endy,int steps): Boolean–uidevice

Slide screen

Rotate the screen

Freezerotation (): Void–uidevice

Disabling the sensor and freezing the device rotation of the current rotation state

Getdisplayrotation (): Int–uidevice

Returns the current rotation state, 0,1,2,3 table represents 0,90,180,270

Serorientationleft (): Void-uidevice

Disable sensor, analog screen device left turn, and fixed position

Setorientationnatural (): Void-uidevice

Disable the sensor, simulate the screen to go to its natural default orientation, and fix the position

Setorientationright (): Void-uidevice

Fixed sensor, analog screen device right turn, and fixed position

Unfreezerotation (): Void-uidevice

Re-enable sensor and allow physical rotation

Isnaturalorientation (): Boolean-uidevice

Check if the unit is in the natural rotation vertical screen position

Kill screen and wake up screens

Wakeup (): Void-uidevice

This method simulates pressing the Power key if the screen has woken up without any effect

Isscreenon (): Boolean-uidevice

Check if the screen wakes up

Sleep (): Void-uidevice

Lock screen (no effect if screen is off)

and waiting for idle

Takescreenshot (File storepath): Boolean–uidevice

Screenshot and save the current window as PNG default 1.0f size (original size) and 90% quality, Storepath as file path

Takescreenshot (File storepath,float scale,int quality): Boolean–uidevice

The current window is a PNG-formatted picture, and you can customize the zoom scale and quality

Scale: Zoom, 1.0 is the original; quality: Picture compression quality, range 1-100

Wait (): Void-object

Sleep until you call notify or Notifyall

Notify (): Void-object

Wakes the thread that is waiting for the object

Notifyall (): Void-object

Evoke all threads that are waiting on the object

Wait (long timeout): Void-object

Wait for * * milliseconds to be awakened

Wait (long Timeout,int Nanos): Void-object

Wait * * * wake up at the end of nanosecond

Waitforidle (): Void-uidevice

Waits for the current application to be idle, default 10S

Waitforidle (Long timeout): Void-uidevice

The custom timeout waits for the current window to be idle

Waitforwindowupdate (String packagename,long timeout): Boolean-uidevice

Wait for the window content update to occur

Get package name, device name

Getcurrentpackagename (): String–uidevice

Get the current package name: Retrieve the package name of the latest accessibility event

Getproductname (): String–uidevice

Get the product device name

Turn on the notification bar to open the quick settings

Opennotification (): Boolean-uidevice

Open the Notification bar

Openquicksettinghs (): Boolean-uidevice

Turn on Quick settings

Get layout file

Getdisplayheight (): Int–uidevice

Gets the display height, in pixels

GETDISPLAYSIZEDP ():P Oint–uidevice

Returns the display dimensions (in DP units), and the returned dimensions are adapted to the rotation of each screen

Getdisplaywidth (): Int–uidevice

Gets the display width, in pixels

Dumpwindowhierachy (String fileName): Void–uidevice

Help method, which is used to debug the layout hierarchy of the Dump current window, the file is saved in/data/local/tmp

Setcompressedlayoutheirarchy (Boolean compressed): Void-uidevice

Enable or disable layout-level compression

Listener

Registerwatcher (String Name,uiwatcher Watcher): Void-uidevice

Register Uiwatcher and run automatically when the test framework cannot find a match using Uiselector

Removewatcher (String name): Void-uidevice

Remove the previously registered Uiwatcher

Resetwatchertriggers (): Void-uidevice

Resets the uiwatcher that have been triggered

Runwatcher (): Void-uidevice

Force all Uiwatcher to run.

Hasanywatchertriggered (): Boolean-uidevice

Check if there is a uiwatcher trigger

Haswatchertriggered (String watchername): Boolean-uidevice

Checks whether a particular listener is triggering

Other

Clearlasttraversedtext (): Void–uidevice

Traverse from past UI events, clear text (last input)

Getcurrentactivityname (): String–uidevice

This method is obsolete and returns a result that is unreliable

Getlasttraversedtext (): String–uidevice

Retrieves the text of the last traversed event received

GetInstance (): Uidevice-uidevice

Retrieving a single Uidevice instance

"Uiautomator" Uidevice

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.