ui

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package ui allows interacting with Android apps by Android UI Automator API. We use android-uiautomator-server, a JSON-RPC server running as an Android app, to invoke UI Automator methods remotely.

Index

Constants

View Source
const (
	// KeyCodes constants
	KEYCODE_UNKNOWN                       KeyCode = 0x0
	KEYCODE_SOFT_LEFT                     KeyCode = 0x1
	KEYCODE_SOFT_RIGHT                    KeyCode = 0x2
	KEYCODE_HOME                          KeyCode = 0x3
	KEYCODE_BACK                          KeyCode = 0x4
	KEYCODE_CALL                          KeyCode = 0x5
	KEYCODE_ENDCALL                       KeyCode = 0x6
	KEYCODE_0                             KeyCode = 0x7
	KEYCODE_1                             KeyCode = 0x8
	KEYCODE_2                             KeyCode = 0x9
	KEYCODE_3                             KeyCode = 0xa
	KEYCODE_4                             KeyCode = 0xb
	KEYCODE_5                             KeyCode = 0xc
	KEYCODE_6                             KeyCode = 0xd
	KEYCODE_7                             KeyCode = 0xe
	KEYCODE_8                             KeyCode = 0xf
	KEYCODE_9                             KeyCode = 0x10
	KEYCODE_STAR                          KeyCode = 0x11
	KEYCODE_POUND                         KeyCode = 0x12
	KEYCODE_DPAD_UP                       KeyCode = 0x13
	KEYCODE_DPAD_DOWN                     KeyCode = 0x14
	KEYCODE_DPAD_LEFT                     KeyCode = 0x15
	KEYCODE_DPAD_RIGHT                    KeyCode = 0x16
	KEYCODE_DPAD_CENTER                   KeyCode = 0x17
	KEYCODE_VOLUME_UP                     KeyCode = 0x18
	KEYCODE_VOLUME_DOWN                   KeyCode = 0x19
	KEYCODE_POWER                         KeyCode = 0x1a
	KEYCODE_CAMERA                        KeyCode = 0x1b
	KEYCODE_CLEAR                         KeyCode = 0x1c
	KEYCODE_A                             KeyCode = 0x1d
	KEYCODE_B                             KeyCode = 0x1e
	KEYCODE_C                             KeyCode = 0x1f
	KEYCODE_D                             KeyCode = 0x20
	KEYCODE_E                             KeyCode = 0x21
	KEYCODE_F                             KeyCode = 0x22
	KEYCODE_G                             KeyCode = 0x23
	KEYCODE_H                             KeyCode = 0x24
	KEYCODE_I                             KeyCode = 0x25
	KEYCODE_J                             KeyCode = 0x26
	KEYCODE_K                             KeyCode = 0x27
	KEYCODE_L                             KeyCode = 0x28
	KEYCODE_M                             KeyCode = 0x29
	KEYCODE_N                             KeyCode = 0x2a
	KEYCODE_O                             KeyCode = 0x2b
	KEYCODE_P                             KeyCode = 0x2c
	KEYCODE_Q                             KeyCode = 0x2d
	KEYCODE_R                             KeyCode = 0x2e
	KEYCODE_S                             KeyCode = 0x2f
	KEYCODE_T                             KeyCode = 0x30
	KEYCODE_U                             KeyCode = 0x31
	KEYCODE_V                             KeyCode = 0x32
	KEYCODE_W                             KeyCode = 0x33
	KEYCODE_X                             KeyCode = 0x34
	KEYCODE_Y                             KeyCode = 0x35
	KEYCODE_Z                             KeyCode = 0x36
	KEYCODE_COMMA                         KeyCode = 0x37
	KEYCODE_PERIOD                        KeyCode = 0x38
	KEYCODE_ALT_LEFT                      KeyCode = 0x39
	KEYCODE_ALT_RIGHT                     KeyCode = 0x3a
	KEYCODE_SHIFT_LEFT                    KeyCode = 0x3b
	KEYCODE_SHIFT_RIGHT                   KeyCode = 0x3c
	KEYCODE_TAB                           KeyCode = 0x3d
	KEYCODE_SPACE                         KeyCode = 0x3e
	KEYCODE_SYM                           KeyCode = 0x3f
	KEYCODE_EXPLORER                      KeyCode = 0x40
	KEYCODE_ENVELOPE                      KeyCode = 0x41
	KEYCODE_ENTER                         KeyCode = 0x42
	KEYCODE_DEL                           KeyCode = 0x43
	KEYCODE_GRAVE                         KeyCode = 0x44
	KEYCODE_MINUS                         KeyCode = 0x45
	KEYCODE_EQUALS                        KeyCode = 0x46
	KEYCODE_LEFT_BRACKET                  KeyCode = 0x47
	KEYCODE_RIGHT_BRACKET                 KeyCode = 0x48
	KEYCODE_BACKSLASH                     KeyCode = 0x49
	KEYCODE_SEMICOLON                     KeyCode = 0x4a
	KEYCODE_APOSTROPHE                    KeyCode = 0x4b
	KEYCODE_SLASH                         KeyCode = 0x4c
	KEYCODE_AT                            KeyCode = 0x4d
	KEYCODE_NUM                           KeyCode = 0x4e
	KEYCODE_HEADSETHOOK                   KeyCode = 0x4f
	KEYCODE_PLUS                          KeyCode = 0x51
	KEYCODE_MENU                          KeyCode = 0x52
	KEYCODE_NOTIFICATION                  KeyCode = 0x53
	KEYCODE_SEARCH                        KeyCode = 0x54
	KEYCODE_MEDIA_PLAY_PAUSE              KeyCode = 0x55
	KEYCODE_MEDIA_STOP                    KeyCode = 0x56
	KEYCODE_MEDIA_NEXT                    KeyCode = 0x57
	KEYCODE_MEDIA_PREVIOUS                KeyCode = 0x58
	KEYCODE_MEDIA_REWIND                  KeyCode = 0x59
	KEYCODE_MEDIA_FAST_FORWARD            KeyCode = 0x5a
	KEYCODE_MUTE                          KeyCode = 0x5b
	KEYCODE_PAGE_UP                       KeyCode = 0x5c
	KEYCODE_PAGE_DOWN                     KeyCode = 0x5d
	KEYCODE_BUTTON_A                      KeyCode = 0x60
	KEYCODE_BUTTON_B                      KeyCode = 0x61
	KEYCODE_BUTTON_C                      KeyCode = 0x62
	KEYCODE_BUTTON_X                      KeyCode = 0x63
	KEYCODE_BUTTON_Y                      KeyCode = 0x64
	KEYCODE_BUTTON_Z                      KeyCode = 0x65
	KEYCODE_BUTTON_L1                     KeyCode = 0x66
	KEYCODE_BUTTON_R1                     KeyCode = 0x67
	KEYCODE_BUTTON_L2                     KeyCode = 0x68
	KEYCODE_BUTTON_R2                     KeyCode = 0x69
	KEYCODE_BUTTON_THUMBL                 KeyCode = 0x6a
	KEYCODE_BUTTON_THUMBR                 KeyCode = 0x6b
	KEYCODE_BUTTON_START                  KeyCode = 0x6c
	KEYCODE_BUTTON_SELECT                 KeyCode = 0x6d
	KEYCODE_BUTTON_MODE                   KeyCode = 0x6e
	KEYCODE_ESCAPE                        KeyCode = 0x6f
	KEYCODE_FORWARD_DEL                   KeyCode = 0x70
	KEYCODE_CTRL_LEFT                     KeyCode = 0x71
	KEYCODE_CTRL_RIGHT                    KeyCode = 0x72
	KEYCODE_CAPS_LOCK                     KeyCode = 0x73
	KEYCODE_SCROLL_LOCK                   KeyCode = 0x74
	KEYCODE_META_LEFT                     KeyCode = 0x75
	KEYCODE_META_RIGHT                    KeyCode = 0x76
	KEYCODE_FUNCTION                      KeyCode = 0x77
	KEYCODE_SYSRQ                         KeyCode = 0x78
	KEYCODE_BREAK                         KeyCode = 0x79
	KEYCODE_MOVE_HOME                     KeyCode = 0x7a
	KEYCODE_MOVE_END                      KeyCode = 0x7b
	KEYCODE_INSERT                        KeyCode = 0x7c
	KEYCODE_FORWARD                       KeyCode = 0x7d
	KEYCODE_MEDIA_PLAY                    KeyCode = 0x7e
	KEYCODE_MEDIA_PAUSE                   KeyCode = 0x7f
	KEYCODE_MEDIA_CLOSE                   KeyCode = 0x80
	KEYCODE_MEDIA_EJECT                   KeyCode = 0x81
	KEYCODE_MEDIA_RECORD                  KeyCode = 0x82
	KEYCODE_F1                            KeyCode = 0x83
	KEYCODE_F2                            KeyCode = 0x84
	KEYCODE_F3                            KeyCode = 0x85
	KEYCODE_F4                            KeyCode = 0x86
	KEYCODE_F5                            KeyCode = 0x87
	KEYCODE_F6                            KeyCode = 0x88
	KEYCODE_F7                            KeyCode = 0x89
	KEYCODE_F8                            KeyCode = 0x8a
	KEYCODE_F9                            KeyCode = 0x8b
	KEYCODE_F10                           KeyCode = 0x8c
	KEYCODE_F11                           KeyCode = 0x8d
	KEYCODE_F12                           KeyCode = 0x8e
	KEYCODE_NUM_LOCK                      KeyCode = 0x8f
	KEYCODE_NUMPAD_0                      KeyCode = 0x90
	KEYCODE_NUMPAD_1                      KeyCode = 0x91
	KEYCODE_NUMPAD_2                      KeyCode = 0x92
	KEYCODE_NUMPAD_3                      KeyCode = 0x93
	KEYCODE_NUMPAD_4                      KeyCode = 0x94
	KEYCODE_NUMPAD_5                      KeyCode = 0x95
	KEYCODE_NUMPAD_6                      KeyCode = 0x96
	KEYCODE_NUMPAD_7                      KeyCode = 0x97
	KEYCODE_NUMPAD_8                      KeyCode = 0x98
	KEYCODE_NUMPAD_9                      KeyCode = 0x99
	KEYCODE_NUMPAD_DIVIDE                 KeyCode = 0x9a
	KEYCODE_NUMPAD_MULTIPLY               KeyCode = 0x9b
	KEYCODE_NUMPAD_SUBTRACT               KeyCode = 0x9c
	KEYCODE_NUMPAD_ADD                    KeyCode = 0x9d
	KEYCODE_NUMPAD_DOT                    KeyCode = 0x9e
	KEYCODE_NUMPAD_COMMA                  KeyCode = 0x9f
	KEYCODE_NUMPAD_ENTER                  KeyCode = 0xa0
	KEYCODE_NUMPAD_EQUALS                 KeyCode = 0xa1
	KEYCODE_NUMPAD_LEFT_PAREN             KeyCode = 0xa2
	KEYCODE_NUMPAD_RIGHT_PAREN            KeyCode = 0xa3
	KEYCODE_VOLUME_MUTE                   KeyCode = 0xa4
	KEYCODE_INFO                          KeyCode = 0xa5
	KEYCODE_CHANNEL_UP                    KeyCode = 0xa6
	KEYCODE_CHANNEL_DOWN                  KeyCode = 0xa7
	KEYCODE_ZOOM_IN                       KeyCode = 0xa8
	KEYCODE_ZOOM_OUT                      KeyCode = 0xa9
	KEYCODE_TV                            KeyCode = 0xaa
	KEYCODE_WINDOW                        KeyCode = 0xab
	KEYCODE_GUIDE                         KeyCode = 0xac
	KEYCODE_DVR                           KeyCode = 0xad
	KEYCODE_BOOKMARK                      KeyCode = 0xae
	KEYCODE_CAPTIONS                      KeyCode = 0xaf
	KEYCODE_SETTINGS                      KeyCode = 0xb0
	KEYCODE_TV_POWER                      KeyCode = 0xb1
	KEYCODE_TV_INPUT                      KeyCode = 0xb2
	KEYCODE_STB_POWER                     KeyCode = 0xb3
	KEYCODE_STB_INPUT                     KeyCode = 0xb4
	KEYCODE_AVR_POWER                     KeyCode = 0xb5
	KEYCODE_AVR_INPUT                     KeyCode = 0xb6
	KEYCODE_PROG_RED                      KeyCode = 0xb7
	KEYCODE_PROG_GREEN                    KeyCode = 0xb8
	KEYCODE_PROG_YELLOW                   KeyCode = 0xb9
	KEYCODE_PROG_BLUE                     KeyCode = 0xba
	KEYCODE_APP_SWITCH                    KeyCode = 0xbb
	KEYCODE_BUTTON_1                      KeyCode = 0xbc
	KEYCODE_BUTTON_2                      KeyCode = 0xbd
	KEYCODE_BUTTON_3                      KeyCode = 0xbe
	KEYCODE_BUTTON_4                      KeyCode = 0xbf
	KEYCODE_BUTTON_5                      KeyCode = 0xc0
	KEYCODE_BUTTON_6                      KeyCode = 0xc1
	KEYCODE_BUTTON_7                      KeyCode = 0xc2
	KEYCODE_BUTTON_8                      KeyCode = 0xc3
	KEYCODE_BUTTON_9                      KeyCode = 0xc4
	KEYCODE_BUTTON_10                     KeyCode = 0xc5
	KEYCODE_BUTTON_11                     KeyCode = 0xc6
	KEYCODE_BUTTON_12                     KeyCode = 0xc7
	KEYCODE_BUTTON_13                     KeyCode = 0xc8
	KEYCODE_BUTTON_14                     KeyCode = 0xc9
	KEYCODE_BUTTON_15                     KeyCode = 0xca
	KEYCODE_BUTTON_16                     KeyCode = 0xcb
	KEYCODE_LANGUAGE_SWITCH               KeyCode = 0xcc
	KEYCODE_MANNER_MODE                   KeyCode = 0xcd
	KEYCODE_3D_MODE                       KeyCode = 0xce
	KEYCODE_CONTACTS                      KeyCode = 0xcf
	KEYCODE_CALENDAR                      KeyCode = 0xd0
	KEYCODE_MUSIC                         KeyCode = 0xd1
	KEYCODE_CALCULATOR                    KeyCode = 0xd2
	KEYCODE_ZENKAKU_HANKAKU               KeyCode = 0xd3
	KEYCODE_EISU                          KeyCode = 0xd4
	KEYCODE_MUHENKAN                      KeyCode = 0xd5
	KEYCODE_HENKAN                        KeyCode = 0xd6
	KEYCODE_KATAKANA_HIRAGANA             KeyCode = 0xd7
	KEYCODE_YEN                           KeyCode = 0xd8
	KEYCODE_RO                            KeyCode = 0xd9
	KEYCODE_KANA                          KeyCode = 0xda
	KEYCODE_ASSIST                        KeyCode = 0xdb
	KEYCODE_BRIGHTNESS_DOWN               KeyCode = 0xdc
	KEYCODE_BRIGHTNESS_UP                 KeyCode = 0xdd
	KEYCODE_MEDIA_AUDIO_TRACK             KeyCode = 0xde
	KEYCODE_SLEEP                         KeyCode = 0xdf
	KEYCODE_WAKEUP                        KeyCode = 0xe0
	KEYCODE_PAIRING                       KeyCode = 0xe1
	KEYCODE_MEDIA_TOP_MENU                KeyCode = 0xe2
	KEYCODE_11                            KeyCode = 0xe3
	KEYCODE_12                            KeyCode = 0xe4
	KEYCODE_LAST_CHANNEL                  KeyCode = 0xe5
	KEYCODE_TV_DATA_SERVICE               KeyCode = 0xe6
	KEYCODE_VOICE_ASSIST                  KeyCode = 0xe7
	KEYCODE_TV_RADIO_SERVICE              KeyCode = 0xe8
	KEYCODE_TV_TELETEXT                   KeyCode = 0xe9
	KEYCODE_TV_NUMBER_ENTRY               KeyCode = 0xea
	KEYCODE_TV_TERRESTRIAL_ANALOG         KeyCode = 0xeb
	KEYCODE_TV_TERRESTRIAL_DIGITAL        KeyCode = 0xec
	KEYCODE_TV_SATELLITE                  KeyCode = 0xed
	KEYCODE_TV_SATELLITE_BS               KeyCode = 0xee
	KEYCODE_TV_SATELLITE_CS               KeyCode = 0xef
	KEYCODE_TV_SATELLITE_SERVICE          KeyCode = 0xf0
	KEYCODE_TV_NETWORK                    KeyCode = 0xf1
	KEYCODE_TV_ANTENNA_CABLE              KeyCode = 0xf2
	KEYCODE_TV_INPUT_HDMI_1               KeyCode = 0xf3
	KEYCODE_TV_INPUT_HDMI_2               KeyCode = 0xf4
	KEYCODE_TV_INPUT_HDMI_3               KeyCode = 0xf5
	KEYCODE_TV_INPUT_HDMI_4               KeyCode = 0xf6
	KEYCODE_TV_INPUT_COMPOSITE_1          KeyCode = 0xf7
	KEYCODE_TV_INPUT_COMPOSITE_2          KeyCode = 0xf8
	KEYCODE_TV_INPUT_COMPONENT_1          KeyCode = 0xf9
	KEYCODE_TV_INPUT_COMPONENT_2          KeyCode = 0xfa
	KEYCODE_TV_INPUT_VGA_1                KeyCode = 0xfb
	KEYCODE_TV_AUDIO_DESCRIPTION          KeyCode = 0xfc
	KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP   KeyCode = 0xfd
	KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN KeyCode = 0xfe
	KEYCODE_TV_ZOOM_MODE                  KeyCode = 0xff
	KEYCODE_TV_CONTENTS_MENU              KeyCode = 0x100
	KEYCODE_TV_MEDIA_CONTEXT_MENU         KeyCode = 0x101
	KEYCODE_TV_TIMER_PROGRAMMING          KeyCode = 0x102
	KEYCODE_HELP                          KeyCode = 0x103
	KEYCODE_NAVIGATE_PREVIOUS             KeyCode = 0x104
	KEYCODE_NAVIGATE_NEXT                 KeyCode = 0x105
	KEYCODE_NAVIGATE_IN                   KeyCode = 0x106
	KEYCODE_NAVIGATE_OUT                  KeyCode = 0x107
	KEYCODE_STEM_PRIMARY                  KeyCode = 0x108
	KEYCODE_STEM_1                        KeyCode = 0x109
	KEYCODE_STEM_2                        KeyCode = 0x10a
	KEYCODE_STEM_3                        KeyCode = 0x10b
	KEYCODE_DPAD_UP_LEFT                  KeyCode = 0x10c
	KEYCODE_DPAD_DOWN_LEFT                KeyCode = 0x10d
	KEYCODE_DPAD_UP_RIGHT                 KeyCode = 0x10e
	KEYCODE_DPAD_DOWN_RIGHT               KeyCode = 0x10f
	KEYCODE_MEDIA_SKIP_FORWARD            KeyCode = 0x110
	KEYCODE_MEDIA_SKIP_BACKWARD           KeyCode = 0x111
	KEYCODE_MEDIA_STEP_FORWARD            KeyCode = 0x112
	KEYCODE_MEDIA_STEP_BACKWARD           KeyCode = 0x113
	KEYCODE_SOFT_SLEEP                    KeyCode = 0x114
	KEYCODE_CUT                           KeyCode = 0x115
	KEYCODE_COPY                          KeyCode = 0x116
	KEYCODE_PASTE                         KeyCode = 0x117
	KEYCODE_SYSTEM_NAVIGATION_UP          KeyCode = 0x118
	KEYCODE_SYSTEM_NAVIGATION_DOWN        KeyCode = 0x119
	KEYCODE_SYSTEM_NAVIGATION_LEFT        KeyCode = 0x11a
	KEYCODE_SYSTEM_NAVIGATION_RIGHT       KeyCode = 0x11b
	KEYCODE_ALL_APPS                      KeyCode = 0x11c
	KEYCODE_REFRESH                       KeyCode = 0x11d
	KEYCODE_THUMBS_UP                     KeyCode = 0x11e
	KEYCODE_THUMBS_DOWN                   KeyCode = 0x11f
	KEYCODE_PROFILE_SWITCH                KeyCode = 0x120

	// Meta-key constants
	META_SHIFT_ON       MetaState = 0x1
	META_ALT_ON         MetaState = 0x2
	META_SYM_ON         MetaState = 0x4
	META_FUNCTION_ON    MetaState = 0x8
	META_ALT_LEFT_ON    MetaState = 0x10
	META_ALT_RIGHT_ON   MetaState = 0x20
	META_SHIFT_LEFT_ON  MetaState = 0x40
	META_SHIFT_RIGHT_ON MetaState = 0x80
	META_CAP_LOCKED     MetaState = 0x100
	META_ALT_LOCKED     MetaState = 0x200
	META_SYM_LOCKED     MetaState = 0x400
	META_SELECTING      MetaState = 0x800
	META_CTRL_ON        MetaState = 0x1000
	META_CTRL_LEFT_ON   MetaState = 0x2000
	META_CTRL_RIGHT_ON  MetaState = 0x4000
	META_META_ON        MetaState = 0x10000
	META_META_LEFT_ON   MetaState = 0x20000
	META_META_RIGHT_ON  MetaState = 0x40000
	META_CAPS_LOCK_ON   MetaState = 0x100000
	META_NUM_LOCK_ON    MetaState = 0x200000
	META_SCROLL_LOCK_ON MetaState = 0x400000
)
View Source
const (
	// StartTimeout is the timeout of NewDevice.
	StartTimeout = 120 * time.Second
)

Variables

This section is empty.

Functions

func IsTimeout

func IsTimeout(err error) bool

IsTimeout returns true if the given error is of type ErrorTimeout.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device provides access to state information about the Android system.

Close must be called to clean up resources when a test is over.

This object corresponds to UiDevice in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiDevice

func NewDevice

func NewDevice(ctx context.Context, d *adb.Device) (*Device, error)

NewDevice creates a Device object by starting and connecting to UI Automator server. Close must be called to clean up resources when a test is over.

func NewDeviceWithRetry

func NewDeviceWithRetry(ctx context.Context, d *adb.Device) (*Device, error)

NewDeviceWithRetry creates a Device object by starting and connecting to UI Automator server. Retries, in case of an error. Close must be called to clean up resources when a test is over.

func (*Device) Alive

func (d *Device) Alive(ctx context.Context) bool

Alive returns true if UI Automator server is responding.

func (*Device) Click

func (d *Device) Click(ctx context.Context, x, y int) error

Click performs a click at arbitrary coordinates specified by the user. This method corresponds to UiDevice.click(int, int) https://developer.android.com/reference/android/support/test/uiautomator/UiDevice.html#click

func (*Device) Close

func (d *Device) Close(ctx context.Context) error

Close releases resources associated with d.

func (*Device) EnableDebug

func (d *Device) EnableDebug()

EnableDebug enables verbose RPC logging.

func (*Device) GetInfo

func (d *Device) GetInfo(ctx context.Context) (*DeviceInfo, error)

GetInfo returns the device info. This method corresponds to the com.github.uiautomator.stub.getDeviceInfo(). https://github.com/xiaocong/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/DeviceInfo.java // nocheck

func (*Device) Object

func (d *Device) Object(opts ...SelectorOption) *Object

Object creates an Object from given selectors.

Example:

btn := d.Object(ui.ID("foo_button"), ui.Text("bar"))

func (*Device) PressKeyCode

func (d *Device) PressKeyCode(ctx context.Context, keyCode KeyCode, metaState MetaState) error

PressKeyCode simulates a short press using a key code. keyCode is the key code. metaState represents the meta keys. Each bit represents a pressed meta key. This method corresponds to UiDevice.pressKeyCode(int, int) https://developer.android.com/reference/android/support/test/uiautomator/UiDevice#presskeycode

func (*Device) WaitForIdle

func (d *Device) WaitForIdle(ctx context.Context, timeout time.Duration) error

WaitForIdle waits for the current application to idle. This method corresponds to UiDevice.waitForIdle(long). https://developer.android.com/reference/android/support/test/uiautomator/UiDevice.html#waitForIdle(long)

func (*Device) WaitForWindowUpdate

func (d *Device) WaitForWindowUpdate(ctx context.Context, packageName string, timeout time.Duration) (eventOcurred bool, err error)

WaitForWindowUpdate waits for a window content update event to occur. If a package name for the window is specified, but the current window does not have the same package name, the function returns eventOcurred=false, but no error is generated. Returns true if a window update occurred, false if timeout has elapsed or if the current window does not have the specified package name. This method corresponds to UiDevice.waitForWindowUpdate(string, long). https://developer.android.com/reference/android/support/test/uiautomator/UiDevice.html#waitforwindowupdate

type DeviceInfo

type DeviceInfo struct {
	CurrentPackagename string `json:"currentPackagename"`
	DisplayWidth       int    `json:"displayWidth"`
	DisplayHeight      int    `json:"displayHeight"`
	DisplayRotation    int    `json:"displayRotation"`
	DisplaySizeDpX     int    `json:"displaySizeDpX"`
	DisplaySizeDpY     int    `json:"displaySizeDpY"`
	ProductName        string `json:"productName"`
	NaturalOrientation bool   `json:"naturalOrientation"`
	ScreenOn           bool   `json:"screenOn"`
	SDKInt             int    `json:"sdkInt"`
}

DeviceInfo holds information about the device. See: https://github.com/xiaocong/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/DeviceInfo.java // nocheck

type ErrorTimeout

type ErrorTimeout struct {
	*errors.E
}

ErrorTimeout defines an error for the ui timeout.

type KeyCode

type KeyCode uint16

KeyCode represents an Android key code.

type MetaState

type MetaState uint64

MetaState represents a meta-key state. Each bit set to 1 represents a pressed meta key.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object is a representation of an Android view.

An instantiated Object does NOT uniquely identify an Android view. Instead, it holds a selector to locate a matching view when its methods are called. Once you create an instance of Object, it can be reused for different views matching the selector.

This object corresponds to UiObject in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiObject

func (*Object) Click

func (o *Object) Click(ctx context.Context) error

Click clicks a view matching the selector.

This method corresponds to UiObject.click(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#click

func (*Object) Exists

func (o *Object) Exists(ctx context.Context) error

Exists returns if an object exists.

This method corresponds to UiObject.exists(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#exists

func (*Object) GetBounds

func (o *Object) GetBounds(ctx context.Context) (coords.Rect, error)

GetBounds returns the bounds of a view.

This method corresponds to UiObject.getBounds(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#getbounds

func (*Object) GetChild

func (o *Object) GetChild(ctx context.Context, target *Object) error

GetChild Creates a new UiObject for a child view that is under the present UiObject

This method corresponds to UiObject.getChild(). https://developer.android.com/reference/androidx/test/uiautomator/UiObject#getchild

func (*Object) GetChildCount

func (o *Object) GetChildCount(ctx context.Context) (int, error)

GetChildCount returns the count of child views immediately under the present UiObject.

This method corresponds to UiObject.getChildCount(). https://developer.android.com/reference/androidx/test/uiautomator/UiObject#getchildcount

func (*Object) GetClassName

func (o *Object) GetClassName(ctx context.Context) (string, error)

GetClassName returns the class name of a view.

This method corresponds to UiObject.getClassName(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#getclassname

func (*Object) GetContentDescription

func (o *Object) GetContentDescription(ctx context.Context) (string, error)

GetContentDescription returns the content description property of a view.

This method corresponds to UiObject.getContentDescription(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#getcontentdescription

func (*Object) GetObject

func (o *Object) GetObject(ctx context.Context) error

GetObject assigns the UI Object ID to the object so it can be used in subsequent calls to the same object.

It is the interface for getUiObject() method of UI Automator server.

func (*Object) GetPackageName

func (o *Object) GetPackageName(ctx context.Context) (string, error)

GetPackageName returns the package name of a view.

This method corresponds to UiObject.getPackageName(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#getpackagename

func (*Object) GetText

func (o *Object) GetText(ctx context.Context) (string, error)

GetText returns the text property of a view.

This method corresponds to UiObject.getText(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#gettext

func (*Object) IsCheckable

func (o *Object) IsCheckable(ctx context.Context) (bool, error)

IsCheckable returns if a view is checkable.

This method corresponds to UiObject.isCheckable(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#ischeckable

func (*Object) IsChecked

func (o *Object) IsChecked(ctx context.Context) (bool, error)

IsChecked returns if a view is checked.

This method corresponds to UiObject.isChecked(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#ischecked

func (*Object) IsClickable

func (o *Object) IsClickable(ctx context.Context) (bool, error)

IsClickable returns if a view is clickable.

This method corresponds to UiObject.isClickable(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isclickable

func (*Object) IsEnabled

func (o *Object) IsEnabled(ctx context.Context) (bool, error)

IsEnabled returns if a view is enabled.

This method corresponds to UiObject.isEnabled(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isenabled

func (*Object) IsFocusable

func (o *Object) IsFocusable(ctx context.Context) (bool, error)

IsFocusable returns if a view is focusable.

This method corresponds to UiObject.isFocusable(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isfocusable

func (*Object) IsFocused

func (o *Object) IsFocused(ctx context.Context) (bool, error)

IsFocused returns if a view is focused.

This method corresponds to UiObject.isFocused(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isfocused

func (*Object) IsLongClickable

func (o *Object) IsLongClickable(ctx context.Context) (bool, error)

IsLongClickable returns if a view is longClickable.

This method corresponds to UiObject.isLongClickable(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#islongclickable

func (*Object) IsScrollable

func (o *Object) IsScrollable(ctx context.Context) (bool, error)

IsScrollable returns if a view is scrollable.

This method corresponds to UiObject.isScrollable(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isscrollable

func (*Object) IsSelected

func (o *Object) IsSelected(ctx context.Context) (bool, error)

IsSelected returns if a view is selected.

This method corresponds to UiObject.isSelected(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#isselected

func (*Object) ScrollBackward

func (o *Object) ScrollBackward(ctx context.Context, n int) (bool, error)

ScrollBackward returns true if scrolled, false if can't scroll anymore.

ScrollBackward performs a backward scroll action with n number of scroll steps in vertical direction from top to bottom. This method corresponds to UiScrollable.scrollBackward(). https://developer.android.com/reference/androidx/test/uiautomator/UiScrollable#scrollbackward

func (*Object) ScrollForward

func (o *Object) ScrollForward(ctx context.Context, n int) (bool, error)

ScrollForward returns true if scrolled, false if can't scroll anymore.

ScrollForward performs a forward scroll action with n number of scroll steps in vertical direction from bottom to top. This method corresponds to UiScrollable.scrollForward(). https://developer.android.com/reference/androidx/test/uiautomator/UiScrollable#scrollforward

func (*Object) ScrollTo

func (o *Object) ScrollTo(ctx context.Context, target *Object) error

ScrollTo performs a forward scroll action to move through the scrollable layout element until a view matching the target selector is found.

This method corresponds to UiScrollable.scrollintoview(). https://developer.android.com/reference/androidx/test/uiautomator/UiScrollable.html#scrollintoview

func (*Object) SetText

func (o *Object) SetText(ctx context.Context, s string) error

SetText sets the text property of a view.

This method corresponds to UiObject.setText(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#settext

func (*Object) SwipeDown

func (o *Object) SwipeDown(ctx context.Context, steps int) error

SwipeDown performs the swipe down action on the UiObject steps indicates the number of injected move steps into the system. Steps are injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.

This method corresponds to UiObject.SwipeDown(). https://github.com/lnishan/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java

func (*Object) SwipeLeft

func (o *Object) SwipeLeft(ctx context.Context, steps int) error

SwipeLeft performs the swipe left action on the UiObject steps indicates the number of injected move steps into the system. Steps are injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.

This method corresponds to UiObject.SwipeLeft(). https://github.com/lnishan/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java

func (*Object) SwipeRight

func (o *Object) SwipeRight(ctx context.Context, steps int) error

SwipeRight performs the swipe right action on the UiObject steps indicates the number of injected move steps into the system. Steps are injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.

This method corresponds to UiObject.SwipeRight(). https://github.com/lnishan/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java

func (*Object) SwipeUp

func (o *Object) SwipeUp(ctx context.Context, steps int) error

SwipeUp performs the swipe up action on the UiObject steps indicates the number of injected move steps into the system. Steps are injected about 5ms apart. So a 100 steps may take about 1/2 second to complete.

This method corresponds to UiObject.SwipeUp(). https://github.com/lnishan/android-uiautomator-server/blob/master/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java

func (*Object) WaitForExists

func (o *Object) WaitForExists(ctx context.Context, timeout time.Duration) error

WaitForExists waits for a view matching the selector to appear.

This method corresponds to UiObject.waitForExists(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#waitForExists(long)

func (*Object) WaitForText

func (o *Object) WaitForText(ctx context.Context, expected string, timeout time.Duration) error

WaitForText waits for a text view matching the selector to have the expected text.

func (*Object) WaitUntilGone

func (o *Object) WaitUntilGone(ctx context.Context, timeout time.Duration) error

WaitUntilGone waits for a view matching the selector to disappear.

This method corresponds to UiObject.waitUntilGone(). https://developer.android.com/reference/android/support/test/uiautomator/UiObject.html#waitUntilGone(long)

type SelectorOption

type SelectorOption func(s *selector)

SelectorOption specifies UI element selection criteria.

func Checkable

func Checkable(b bool) SelectorOption

Checkable limits the selection criteria by if an object is checkable.

This corresponds to UiSelector.checkable in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#checkable(boolean)

func Checked

func Checked(b bool) SelectorOption

Checked limits the selection criteria by if an object is checked.

This corresponds to UiSelector.checked in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#checked(boolean)

func ClassName

func ClassName(name string) SelectorOption

ClassName limits the selection criteria by class property.

This corresponds to UiSelector.className in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#className(java.lang.String)

func ClassNameMatches

func ClassNameMatches(name string) SelectorOption

ClassNameMatches limits the selection criteria by regex matching class property.

This corresponds to UiSelector.classNameMatches in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#classNameMatches(java.lang.String)

func Clickable

func Clickable(b bool) SelectorOption

Clickable limits the selection criteria by if an object is clickable.

This corresponds to UiSelector.clickable in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#clickable(boolean)

func Description

func Description(desc string) SelectorOption

Description limits the selection criteria by description property.

This corresponds to UiSelector.description in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#description(java.lang.String)

func DescriptionContains

func DescriptionContains(desc string) SelectorOption

DescriptionContains limits the selection criteria by substring of description property.

This corresponds to UiSelector.descriptionContains in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#descriptionContains(java.lang.String)

func DescriptionMatches

func DescriptionMatches(regex string) SelectorOption

DescriptionMatches limits the selection criteria by regex matching description property.

This corresponds to UiSelector.descriptionMatches in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#descriptionMatches(java.lang.String)

func DescriptionStartsWith

func DescriptionStartsWith(desc string) SelectorOption

DescriptionStartsWith limits the selection criteria by prefix of description property.

This corresponds to UiSelector.descriptionStartsWith in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#descriptionStartsWith(java.lang.String)

func Enabled

func Enabled(b bool) SelectorOption

Enabled limits the selection criteria by if an object is enabled.

This corresponds to UiSelector.enabled in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#enabled(boolean)

func Focusable

func Focusable(b bool) SelectorOption

Focusable limits the selection criteria by if an object is focusable.

This corresponds to UiSelector.focusable in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#focusable(boolean)

func Focused

func Focused(b bool) SelectorOption

Focused limits the selection criteria by if an object is focused.

This corresponds to UiSelector.focused in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#focused(boolean)

func ID

func ID(resourceID string) SelectorOption

ID is an alias of ResourceID.

func Index

func Index(i int) SelectorOption

Index limits the selection criteria by node index.

This corresponds to UiSelector.index in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#index(int)

func Instance

func Instance(i int) SelectorOption

Instance limits the selection criteria by instance number.

This corresponds to UiSelector.instance in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#instance(int)

func LongClickable

func LongClickable(b bool) SelectorOption

LongClickable limits the selection criteria by if an object is long-clickable.

This corresponds to UiSelector.longClickable in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#longClickable(boolean)

func PackageName

func PackageName(pkg string) SelectorOption

PackageName limits the selection criteria by package name.

This corresponds to UiSelector.packageName in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#packageName(java.lang.String)

func PackageNameMatches

func PackageNameMatches(regex string) SelectorOption

PackageNameMatches limits the selection criteria by regex matching package name.

This corresponds to UiSelector.packageNameMatches in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#packageNameMatches(java.lang.String)

func ResourceID

func ResourceID(resourceID string) SelectorOption

ResourceID limits the selection criteria by resource ID.

This corresponds to UiSelector.resourceId in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#resourceId(java.lang.String)

func ResourceIDMatches

func ResourceIDMatches(regex string) SelectorOption

ResourceIDMatches limits the selection criteria by regex matching resource ID.

This corresponds to UiSelector.resourceIdMatches in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#resourceIdMatches(java.lang.String)

func Scrollable

func Scrollable(b bool) SelectorOption

Scrollable limits the selection criteria by if an object is scrollable.

This corresponds to UiSelector.scrollable in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#scrollable(boolean)

func Selected

func Selected(b bool) SelectorOption

Selected limits the selection criteria by if an object is selected.

This corresponds to UiSelector.selected in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#selected(boolean)

func Text

func Text(text string) SelectorOption

Text limits the selection criteria by text property.

This corresponds to UiSelector.text in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#text(java.lang.String)

func TextContains

func TextContains(text string) SelectorOption

TextContains limits the selection criteria by substring of text property.

This corresponds to UiSelector.textContains in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#textContains(java.lang.String)

func TextMatches

func TextMatches(regex string) SelectorOption

TextMatches limits the selection criteria by regex matching text property.

This corresponds to UiSelector.textMatches in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#textMatches(java.lang.String)

func TextStartsWith

func TextStartsWith(text string) SelectorOption

TextStartsWith limits the selection criteria by prefix of text property.

This corresponds to UiSelector.textStartsWith in UI Automator API: https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#textStartsWith(java.lang.String)

Directories

Path Synopsis
Package main implements a script for writing a Go source file containing input event constants.
Package main implements a script for writing a Go source file containing input event constants.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL