Documentation
¶
Overview ¶
* https://github.com/openatx/uiautomator2#app-management
* Device api related https://github.com/openatx/uiautomator2#retrieve-the-device-info
* Gesture interaction with the device https://github.com/openatx/uiautomator2#gesture-interaction-with-the-device
* https://github.com/openatx/uiautomator2#input-method
* Screen api related https://github.com/openatx/uiautomator2#screen-related
* Selector is a handy mechanism to identify a specific UI object in the current window. https://github.com/openatx/uiautomator2#selector
Index ¶
- Constants
- type AppInfo
- type Config
- type DeviceInfo
- type Element
- func (ele Element) Center(offset *Position) (*Position, error)
- func (ele Element) Child(selector Selector) *Element
- func (ele *Element) ChildByDescription(keywords string, selector Selector) (*Element, error)
- func (ele *Element) ChildByText(keywords string, selector Selector) (*Element, error)
- func (ele Element) ClearText() error
- func (ele *Element) Click(offset *Position) error
- func (ele *Element) ClickNoWait(offset *Position) error
- func (ele Element) Clone() *Element
- func (ele Element) Count() (int, error)
- func (ele Element) Eq(index int) *Element
- func (ele Element) GetInfo() (*ElementInfo, error)
- func (ele Element) GetRect() (rect *ElementRect, err error)
- func (ele Element) GetText() (string, error)
- func (ele Element) GetTextNoWait() (string, error)
- func (ele *Element) LongClick() error
- func (ele *Element) ScrollDown(step int) error
- func (ele *Element) ScrollTo(selector Selector) error
- func (ele *Element) ScrollToBeginning() error
- func (ele *Element) ScrollToEnd() error
- func (ele *Element) ScrollUp(step int) error
- func (ele Element) SetText(text string) error
- func (ele *Element) Sibling(selector Selector) (*Element, error)
- func (ele *Element) SwipeDown() error
- func (ele *Element) SwipeLeft() error
- func (ele *Element) SwipeRight() error
- func (ele *Element) SwipeUp() error
- func (ele Element) WaitForExists(duration float32, maxRetry int) error
- func (ele Element) WaitUntilGone(duration float32, maxRetry int) error
- type ElementInfo
- type ElementRect
- type GatewayError
- type ORIENTATION
- type Position
- type RPCOptions
- type Screenshot
- type Selector
- type SessionError
- type Toast
- type UIAutomator
- func (ua *UIAutomator) AppClear(packageName string) error
- func (ua *UIAutomator) AppInstall(url string) error
- func (ua *UIAutomator) AppStart(packageName string) error
- func (ua *UIAutomator) AppStop(packageName string) error
- func (ua *UIAutomator) AppWait(packageName string) error
- func (ua *UIAutomator) Click(position *Position) error
- func (ua *UIAutomator) DbClick(position *Position, duration float32) error
- func (ua *UIAutomator) Drag(start *Position, end *Position, duration float32) error
- func (ua *UIAutomator) DumpWindowHierarchy() (string, error)
- func (ua *UIAutomator) FreezeRotation(freeze bool) error
- func (ua UIAutomator) GetConfig() *Config
- func (ua *UIAutomator) GetCurrentApp() (info *AppInfo, err error)
- func (ua *UIAutomator) GetDeviceInfo() (*DeviceInfo, error)
- func (ua *UIAutomator) GetElementBySelector(selector Selector) (ele *Element)
- func (ua *UIAutomator) GetScreenshot() (*Screenshot, error)
- func (ua *UIAutomator) GetSerialNumber() (string, error)
- func (ua *UIAutomator) GetWindowSize() (*WindowSize, error)
- func (ua *UIAutomator) IsSleep() (res bool, err error)
- func (ua *UIAutomator) IsWakeUp() (res bool, err error)
- func (ua *UIAutomator) LongClick(position *Position, duration float32) error
- func (ua *UIAutomator) NewToast() *Toast
- func (ua *UIAutomator) OpenNotification() error
- func (ua *UIAutomator) OpenQuickSettings() error
- func (ua *UIAutomator) Ping() (status string, err error)
- func (ua *UIAutomator) Press(key string) error
- func (ua *UIAutomator) PressKeyCode(key int, meta interface{}) error
- func (ua *UIAutomator) SendAction(code interface{}) error
- func (ua *UIAutomator) SetFastinputIME(enable bool) error
- func (ua *UIAutomator) SetOrientationLeft() error
- func (ua *UIAutomator) SetOrientationNatural() error
- func (ua *UIAutomator) SetOrientationRight() error
- func (ua *UIAutomator) SetOrientationUpsidedown() error
- func (ua *UIAutomator) Shell(command string) (output string, err error)
- func (ua *UIAutomator) Sleep() error
- func (ua *UIAutomator) Swipe(from *Position, to *Position, step int) error
- func (ua *UIAutomator) SwipePoints(points ...*Position) error
- func (ua *UIAutomator) Unlock() error
- func (ua *UIAutomator) WakeUp() error
- func (ua *UIAutomator) Watchman() *Watcher
- type UiaError
- type Watcher
- type WindowSize
Constants ¶
const ( ORIENTATION_RIGHT = "right" ORIENTATION_LEFT = "left" ORIENTATION_NATURAL = "natural" ORIENTATION_UPSIDEDOWN = "upsidedown" )
const ( VERSION = "0.0.1" BASE_URL = "/jsonrpc/0" TIMEOUT = 30 // Default timeout(second) AUTO_RETRY = 5 // Default retry times RETRY_DURATION = 3 // Default retry duration WAIT_FOR_EXISTS_MAX_RETRY = 3 // Default WaitForExistsMaxRetry WAIT_FOR_EXISTS_DURATION = 0.3 // Default WaitForExistsDuration WAIT_FOR_DISAPPEAR_MAX_RETRY = 3 // Default WaitForDisappearMaxRetry WAIT_FOR_DISAPPEAR_DURATION = 0.3 // Default WaitForDisappearDuration )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string // Server host
Port int // Server port
Timeout int // Timeout(second)
AutoRetry int // Auto retry times, 0 is without retry
RetryDuration int // Retry duration(second)
WaitForExistsDuration float32 // Unit second
WaitForExistsMaxRetry int // Max retry times
WaitForDisappearDuration float32 // Unit second
WaitForDisappearMaxRetry int // Max retry times
}
type DeviceInfo ¶
type DeviceInfo struct {
CurrentPackageName string `json:"currentPackageName"`
DisplayHeight int `json:"displayHeight"`
DisplayWidth int `json:"displayWidth"`
DisplayRotation int `json:"displayRotation"`
DisplaySizeDpX int `json:"displaySizeDpX"`
DisplaySizeDpY int `json:"displaySizeDpY"`
ProductName string `json:"productName"`
ScreenOn bool `json:"screenOn"`
SdkInt int `json:"sdkInt"`
NaturalOrientation bool `json:"naturalOrientation"`
}
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func (*Element) ChildByDescription ¶
func (*Element) ChildByText ¶
func (*Element) ClickNoWait ¶
func (Element) GetRect ¶
func (ele Element) GetRect() (rect *ElementRect, err error)
Get Widget rect bounds
func (Element) GetTextNoWait ¶
func (*Element) ScrollToBeginning ¶
Screen scroll to beginning
func (Element) WaitForExists ¶
Check if the specific UI object exists
type ElementInfo ¶
type ElementInfo struct {
ContentDescription string `json:"contentDescription"`
Checked bool `json:"checked"`
Scrollable bool `json:"scrollable"`
Text string `json:"text"`
PackageName string `json:"packageName"`
Selected bool `json:"selected"`
Enabled bool `json:"enabled"`
ClassName string `json:"className"`
Focused bool `json:"focused"`
Focusable bool `json:"focusable"`
Clickable bool `json:"clickable"`
ChileCount int `json:"chileCount"`
LongClickable bool `json:"longClickable"`
Checkable bool `json:"checkable"`
Bounds *ElementRect `json:"bounds"`
VisibleBounds *ElementRect `json:"visibleBounds"`
}
type ElementRect ¶
type GatewayError ¶
type GatewayError struct {
Message string
}
func (*GatewayError) Error ¶
func (err *GatewayError) Error() string
type ORIENTATION ¶
type ORIENTATION string
type RPCOptions ¶
type Screenshot ¶
type SessionError ¶
type SessionError struct {
Message string
}
func (*SessionError) Error ¶
func (err *SessionError) Error() string
type Toast ¶
type Toast struct {
// contains filtered or unexported fields
}
func (*Toast) GetMessage ¶
Get the toast message TODO: method "getLastToast" not work
type UIAutomator ¶
type UIAutomator struct {
// contains filtered or unexported fields
}
func (*UIAutomator) AppClear ¶
func (ua *UIAutomator) AppClear(packageName string) error
Clear app data
func (*UIAutomator) AppInstall ¶
func (ua *UIAutomator) AppInstall(url string) error
Install an app TODO: api "/install" not work
func (*UIAutomator) AppWait ¶
func (ua *UIAutomator) AppWait(packageName string) error
func (*UIAutomator) Click ¶
func (ua *UIAutomator) Click(position *Position) error
Click on the screen
func (*UIAutomator) DbClick ¶
func (ua *UIAutomator) DbClick(position *Position, duration float32) error
Double click on the screen
func (*UIAutomator) Drag ¶
func (ua *UIAutomator) Drag(start *Position, end *Position, duration float32) error
Swipe the screen
func (*UIAutomator) DumpWindowHierarchy ¶
func (ua *UIAutomator) DumpWindowHierarchy() (string, error)
* Get the UI hierarchy dump content (unicoded).
func (*UIAutomator) FreezeRotation ¶
func (ua *UIAutomator) FreezeRotation(freeze bool) error
Freeze rotation
func (UIAutomator) GetConfig ¶
func (ua UIAutomator) GetConfig() *Config
func (*UIAutomator) GetCurrentApp ¶
func (ua *UIAutomator) GetCurrentApp() (info *AppInfo, err error)
Get current app info
func (*UIAutomator) GetDeviceInfo ¶
func (ua *UIAutomator) GetDeviceInfo() (*DeviceInfo, error)
Get basic information
func (*UIAutomator) GetElementBySelector ¶
func (ua *UIAutomator) GetElementBySelector(selector Selector) (ele *Element)
Query the UI element by selector
func (*UIAutomator) GetScreenshot ¶
func (ua *UIAutomator) GetScreenshot() (*Screenshot, error)
func (*UIAutomator) GetSerialNumber ¶
func (ua *UIAutomator) GetSerialNumber() (string, error)
Get device serial number
func (*UIAutomator) GetWindowSize ¶
func (ua *UIAutomator) GetWindowSize() (*WindowSize, error)
Get window size
func (*UIAutomator) IsSleep ¶
func (ua *UIAutomator) IsSleep() (res bool, err error)
Check device is sleep
func (*UIAutomator) IsWakeUp ¶
func (ua *UIAutomator) IsWakeUp() (res bool, err error)
Check device is wakeup
func (*UIAutomator) LongClick ¶
func (ua *UIAutomator) LongClick(position *Position, duration float32) error
Long click on the screen
func (*UIAutomator) OpenNotification ¶
func (ua *UIAutomator) OpenNotification() error
* Open notification
func (*UIAutomator) OpenQuickSettings ¶
func (ua *UIAutomator) OpenQuickSettings() error
* Open quick settings
func (*UIAutomator) Ping ¶
func (ua *UIAutomator) Ping() (status string, err error)
func (*UIAutomator) PressKeyCode ¶
func (ua *UIAutomator) PressKeyCode(key int, meta interface{}) error
Press key code
func (*UIAutomator) SendAction ¶
func (ua *UIAutomator) SendAction(code interface{}) error
func (*UIAutomator) SetFastinputIME ¶
func (ua *UIAutomator) SetFastinputIME(enable bool) error
func (*UIAutomator) SetOrientationLeft ¶
func (ua *UIAutomator) SetOrientationLeft() error
Set orientation left
func (*UIAutomator) SetOrientationNatural ¶
func (ua *UIAutomator) SetOrientationNatural() error
Set orientation natural
func (*UIAutomator) SetOrientationRight ¶
func (ua *UIAutomator) SetOrientationRight() error
Set orientation right
func (*UIAutomator) SetOrientationUpsidedown ¶
func (ua *UIAutomator) SetOrientationUpsidedown() error
Set orientation upsidedown(not worked)
func (*UIAutomator) Swipe ¶
func (ua *UIAutomator) Swipe(from *Position, to *Position, step int) error
Swipe the screen
func (*UIAutomator) SwipePoints ¶
func (ua *UIAutomator) SwipePoints(points ...*Position) error
Swipe by points, unlock the gesture login
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}