view

package
v0.0.0-...-0ca2631 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package view provides various query and UI operation methods on android UI View. It internally uses uiautomator XML dump mechanism to parse device view hierarchy, so all operations are based on information extracted from XML hierarchy dump. TODO : Detailed package documentation need to be done here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceView

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

func NewDeviceView

func NewDeviceView(dev device.Device) DeviceView

func (DeviceView) CheckCheckboxByResource

func (devView DeviceView) CheckCheckboxByResource(resource string, index int, timeout int) error

func (DeviceView) ClickDescription

func (devView DeviceView) ClickDescription(description string, index int, timeout int) error

func (DeviceView) ClickMatchingDescription

func (devView DeviceView) ClickMatchingDescription(description string, index int, timeout int) error

func (DeviceView) ClickMatchingResource

func (devView DeviceView) ClickMatchingResource(resource string, index int, timeout int) error

func (DeviceView) ClickMatchingResourceAfterText

func (devView DeviceView) ClickMatchingResourceAfterText(resource string, text string, index int, timeout int) error

TODO reduce code duplication

func (DeviceView) ClickMatchingResourceInterruptable

func (devView DeviceView) ClickMatchingResourceInterruptable(resource string, index int, timeout int, control chan bool) error

func (DeviceView) ClickMatchingText

func (devView DeviceView) ClickMatchingText(text string, index int, timeout int) error

func (DeviceView) ClickMatchingType

func (devView DeviceView) ClickMatchingType(typename string, index int, timeout int) error

func (DeviceView) ClickResource

func (devView DeviceView) ClickResource(resource string, index int, timeout int) error

func (DeviceView) ClickText

func (devView DeviceView) ClickText(text string, index int, timeout int) error

func (DeviceView) ClickType

func (devView DeviceView) ClickType(typename string, index int, timeout int) error

func (DeviceView) ClickTypeForMatchingResource

func (devView DeviceView) ClickTypeForMatchingResource(resource string, index int, timeout int) error

func (DeviceView) ClickTypeForMatchingText

func (devView DeviceView) ClickTypeForMatchingText(text string, index int, timeout int) error

func (DeviceView) GetDescriptionForMatchingResource

func (devView DeviceView) GetDescriptionForMatchingResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetDescriptionForMatchingText

func (devView DeviceView) GetDescriptionForMatchingText(text string, index int, timeout int) (string, error)

func (DeviceView) GetDescriptionForMatchingType

func (devView DeviceView) GetDescriptionForMatchingType(typename string, index int, timeout int) (string, error)

func (DeviceView) GetDescriptionForResource

func (devView DeviceView) GetDescriptionForResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetDescriptionForText

func (devView DeviceView) GetDescriptionForText(text string, index int, timeout int) (string, error)

func (DeviceView) GetDescriptionFortype

func (devView DeviceView) GetDescriptionFortype(typename string, index int, timeout int) (string, error)

func (DeviceView) GetHierarchy

func (devView DeviceView) GetHierarchy() (Hierarchy, error)

func (DeviceView) GetResourceForDescription

func (devView DeviceView) GetResourceForDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetResourceForMatchingDescription

func (devView DeviceView) GetResourceForMatchingDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetResourceForMatchingText

func (devView DeviceView) GetResourceForMatchingText(text string, index int, timeout int) (string, error)

func (DeviceView) GetResourceForMatchingTextInterruptable

func (devView DeviceView) GetResourceForMatchingTextInterruptable(text string, index int, timeout int, control chan bool) (string, error)

func (DeviceView) GetResourceForMatchingType

func (devView DeviceView) GetResourceForMatchingType(typename string, index int, timeout int) (string, error)

func (DeviceView) GetResourceForText

func (devView DeviceView) GetResourceForText(text string, index int, timeout int) (string, error)

func (DeviceView) GetResourceForType

func (devView DeviceView) GetResourceForType(typename string, index int, timeout int) (string, error)

func (DeviceView) GetTextForDescription

func (devView DeviceView) GetTextForDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetTextForMatchingDescription

func (devView DeviceView) GetTextForMatchingDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetTextForMatchingResource

func (devView DeviceView) GetTextForMatchingResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetTextForMatchingType

func (devView DeviceView) GetTextForMatchingType(typename string, index int, timeout int) (string, error)

func (DeviceView) GetTextForResource

func (devView DeviceView) GetTextForResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetTextForType

func (devView DeviceView) GetTextForType(typename string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForDescription

func (devView DeviceView) GetTypeForDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForMatchingDescription

func (devView DeviceView) GetTypeForMatchingDescription(description string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForMatchingResource

func (devView DeviceView) GetTypeForMatchingResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForMatchingText

func (devView DeviceView) GetTypeForMatchingText(text string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForResource

func (devView DeviceView) GetTypeForResource(resource string, index int, timeout int) (string, error)

func (DeviceView) GetTypeForText

func (devView DeviceView) GetTypeForText(text string, index int, timeout int) (string, error)

func (DeviceView) GetViewForDescription

func (devView DeviceView) GetViewForDescription(description string, index int, timeout int) (View, error)

func (DeviceView) GetViewForMatchingDescription

func (devView DeviceView) GetViewForMatchingDescription(description string, index int, timeout int) (View, error)

func (DeviceView) GetViewForMatchingResource

func (devView DeviceView) GetViewForMatchingResource(resource string, index int, timeout int) (View, error)

func (DeviceView) GetViewForMatchingText

func (devView DeviceView) GetViewForMatchingText(text string, index int, timeout int) (View, error)

func (DeviceView) GetViewForMatchingType

func (devView DeviceView) GetViewForMatchingType(typename string, index int, timeout int) (View, error)

func (DeviceView) GetViewForResource

func (devView DeviceView) GetViewForResource(resource string, index int, timeout int) (View, error)

func (DeviceView) GetViewForText

func (devView DeviceView) GetViewForText(text string, index int, timeout int) (View, error)

func (DeviceView) GetViewForType

func (devView DeviceView) GetViewForType(typename string, index int, timeout int) (View, error)

func (DeviceView) GetViewes

func (devView DeviceView) GetViewes() (Views, error)

func (DeviceView) IsDescriptionPresent

func (devView DeviceView) IsDescriptionPresent(description string, index int, timeout int) error

func (DeviceView) IsMatchingDescriptionPresnt

func (devView DeviceView) IsMatchingDescriptionPresnt(description string, index int, timeout int) error

func (DeviceView) IsMatchingResourcePresnt

func (devView DeviceView) IsMatchingResourcePresnt(resource string, index int, timeout int) error

func (DeviceView) IsMatchingTextPresnt

func (devView DeviceView) IsMatchingTextPresnt(text string, index int, timeout int) error

func (DeviceView) IsMatchingTypePresnt

func (devView DeviceView) IsMatchingTypePresnt(typename string, index int, timeout int) error

func (DeviceView) IsResourcePresent

func (devView DeviceView) IsResourcePresent(resource string, index int, timeout int) error

func (DeviceView) IsTextPresent

func (devView DeviceView) IsTextPresent(text string, index int, timeout int) error

func (DeviceView) IsTypePresent

func (devView DeviceView) IsTypePresent(typename string, index int, timeout int) error

func (DeviceView) ScrollDownToDescription

func (devView DeviceView) ScrollDownToDescription(description string, index int, maxscroll int) error

func (DeviceView) ScrollDownToMatchingDescription

func (devView DeviceView) ScrollDownToMatchingDescription(description string, index int, maxscroll int) error

func (DeviceView) ScrollDownToMatchingResource

func (devView DeviceView) ScrollDownToMatchingResource(resource string, index int, maxscroll int) error

func (DeviceView) ScrollDownToMatchingText

func (devView DeviceView) ScrollDownToMatchingText(text string, index int, maxscroll int) error

func (DeviceView) ScrollDownToMatchingType

func (devView DeviceView) ScrollDownToMatchingType(typename string, index int, maxscroll int) error

func (DeviceView) ScrollDownToResource

func (devView DeviceView) ScrollDownToResource(resource string, index int, maxscroll int) error

func (DeviceView) ScrollDownToText

func (devView DeviceView) ScrollDownToText(text string, index int, maxscroll int) error

func (DeviceView) ScrollDownToType

func (devView DeviceView) ScrollDownToType(typename string, index int, maxscroll int) error

func (DeviceView) ScrollUpToDescription

func (devView DeviceView) ScrollUpToDescription(description string, index int, maxscroll int) error

func (DeviceView) ScrollUpToMatchingDescription

func (devView DeviceView) ScrollUpToMatchingDescription(description string, index int, maxscroll int) error

func (DeviceView) ScrollUpToMatchingResource

func (devView DeviceView) ScrollUpToMatchingResource(resource string, index int, maxscroll int) error

func (DeviceView) ScrollUpToMatchingText

func (devView DeviceView) ScrollUpToMatchingText(text string, index int, maxscroll int) error

func (DeviceView) ScrollUpToMatchingType

func (devView DeviceView) ScrollUpToMatchingType(typename string, index int, maxscroll int) error

func (DeviceView) ScrollUpToResource

func (devView DeviceView) ScrollUpToResource(resource string, index int, maxscroll int) error

func (DeviceView) ScrollUpToText

func (devView DeviceView) ScrollUpToText(text string, index int, maxscroll int) error

func (DeviceView) ScrollUpToType

func (devView DeviceView) ScrollUpToType(typename string, index int, maxscroll int) error

type Hierarchy

type Hierarchy struct {
	XMLName  xml.Name `xml:"hierarchy"`     // Namespace of the hierarchy
	Rotation string   `xml:"rotation,attr"` // Rotation value of the hierarchy
	NodeList Nodes    `xml:"node"`          // Child nodes in the hierarchy
}

func (Hierarchy) ConvertToViews

func (hierarchy Hierarchy) ConvertToViews() (Views, error)

type Node

type Node struct {
	XMLName       xml.Name `xml:"node"`                // Namespace of the node
	Index         string   `xml:"index,attr"`          // Index of the node
	Resource      string   `xml:"resource-id,attr"`    // Index of the node
	Class         string   `xml:"class,attr"`          // Class of the node
	Package       string   `xml:"package,attr"`        // Package of the node
	Text          string   `xml:"text,attr"`           // Text of the node
	Description   string   `xml:"content-desc,attr"`   // Description of the node
	Checkable     string   `xml:"checkable,attr"`      // Checkable status of the node
	Checked       string   `xml:"checked,attr"`        // Checked status of the node
	Clickable     string   `xml:"clickable,attr"`      // Clickble status of the node
	Enabled       string   `xml:"enabled,attr"`        // Enabled status of the node
	Focusable     string   `xml:"focusable,attr"`      // Focusable status of the node
	Focused       string   `xml:"focused,attr"`        // Focused status of the node
	Scrollable    string   `xml:"scrollable,attr"`     // Scrollable status of the node
	LongClickable string   `xml:"long-clickable,attr"` // Long clickable status of the node
	Password      string   `xml:"password,attr"`       // Password field status of the node
	Selected      string   `xml:"selected,attr"`       // Selection status of the node
	Bounds        string   `xml:"bounds,attr"`         // View bounds of the node
	ChildNodes    Nodes    `xml:"node"`                // Child nodes for this node
}

func (Node) ConvertToView

func (node Node) ConvertToView(treeIndex, parentIndex int) (View, error)

type Nodes

type Nodes []Node

func (Nodes) ConvertToViews

func (nodes Nodes) ConvertToViews(lastAssignedTreeIndex *int, parentIndex int) (Views, error)

type View

type View struct {
	TreeIndex       int            //Index value on the tree representation of the hierarchy.
	TreeParentIndex int            //Index value of the parent node in the tree representation of the hierarchy.
	Index           int            // Index value of the android view component.
	Class           string         // Canonical class name of the android view component.
	Package         string         // Canonical package name of the android view component.
	Resource        string         // Associated resource id (if any) of the view component.
	Text            string         // Associated text (if any) of the view component.
	Description     string         // Associated description (if any) of the view component.
	Clickable       bool           // Boolean value indicating if the view is clickable.
	Checkable       bool           // Boolean value indicating if the view is checkbox or not.
	Checked         bool           // Boolean value indicating if the view is checked or not.
	Enabled         bool           // Boolean value indicating if the view is enabled or not.
	Focusable       bool           // Boolean value indicating if the view is focusable by user or not.
	Focused         bool           // Boolean value indicating if the view is currently focused or not.
	Scrollable      bool           // Boolean value indicating if the view is scrollable or not.
	LongClickable   bool           // Boolean value indicating if the view is long click enabled or not.
	Password        bool           // Boolean value indicating if the view is a password field or not.
	Selected        bool           // Boolean value indicating if the view is currently selected by user or not.
	Bound           geometry.Rect  // Bounding rectangle of the view.
	Center          geometry.Point // Center coordinate of the view.
}

View struct is an internal representation of android ui component. This is generated from uiautomaror XML dump but in a representation that is more suitable for various UI operations by goandroid framework. It is a typed representation of uiautomator node. Some extra fields are calculated for ease of use, such as center of the view, which allows to click the view and index of the view. Index is calculated based on occurence of the node in uiautomator xml dump.

type Views

type Views []View

Views is a type that represents sclice of View structure.

func (Views) GetByDescription

func (views Views) GetByDescription(description string, index int) (View, bool)

GetByDescription method returns a View struct based on excat match of specified text value of views description and index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with exact description text match, empty view is returned with boolean value false indicating view is not found.

func (Views) GetByMatchingDescription

func (views Views) GetByMatchingDescription(description string, index int) (View, bool)

GetByMatchingDescription method returns a View struct on matching text value of description field of the view with specified index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with matching description value, empty view is returned with boolean value false indicating view is not found. Description match is case insensitive.

func (Views) GetByMatchingResource

func (views Views) GetByMatchingResource(resource string, index int) (View, bool)

GetByMatchingResource method returns a View struct on matching text value of resource id with specified index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with matching test value of resource id, empty view is returned with boolean value false indicating view is not found. Resource id match is case insensitive. NOTE : Here resource id represents following "<resource_id>" part only

<package_name>:id/<resource_id>

func (Views) GetByMatchingResourceAfterText

func (views Views) GetByMatchingResourceAfterText(resource string, text string) (View, bool)

func (Views) GetByMatchingText

func (views Views) GetByMatchingText(text string, index int) (View, bool)

GetByMatchingText method returns a View struct on matching text with specified index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with matching text, empty view is returned with boolean value false indicating view is not found. Text match is case insensitive.

func (Views) GetByMatchingType

func (views Views) GetByMatchingType(typename string, index int) (View, bool)

GetByMatchingType method returns a View struct on matching text value of class name field of the view with specified index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with matching class name, empty view is returned with boolean value false indicating view is not found. Class name match is case insensitive.

func (Views) GetByResource

func (views Views) GetByResource(resource string, index int) (View, bool)

GetByResource method returns a View struct based on excat match of specified text value of view resource id and index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with exact resource id match, empty view is returned with boolean value false indicating view is not found. NOTE : Here resource id represents following "<resource_id>" part only

<package_name>:id/<resource_id>

func (Views) GetByText

func (views Views) GetByText(text string, index int) (View, bool)

GetByText method returns a View struct based on excat match of specified text and index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with exact text match, empty view is returned with boolean value false indicating view is not found.

func (Views) GetByType

func (views Views) GetByType(typename string, index int) (View, bool)

GetByType method returns a View struct based on excat match of specified text value of views class name and index. It also returns a boolean value indicating if the match is found or not. Please note that parameter index is zero based index system, that is, index value of first element is zero. If no view is found with exact class name match, empty view is returned with boolean value false indicating view is not found.

Jump to

Keyboard shortcuts

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