webdriver

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultMjpegServerPort = 9100

DefaultMjpegServerPort is the port of the WebDriverAgent MJPEG server (MJPEG_SERVER_PORT on the runner).

Variables

This section is empty.

Functions

func ParseServerURL added in v1.1.0

func ParseServerURL(line string) (string, bool)

ParseServerURL finds the server URL that WebDriverAgent logs as "ServerURLHere->http://…:8100<-ServerURLHere".

Types

type AppInfo

type AppInfo struct {
	Value     AppInfoValue `json:"value"`
	SessionId string       `json:"sessionId"`
}

type AppInfoValue

type AppInfoValue struct {
	ProcessArguments struct {
		Env struct {
		} `json:"env"`
		Args []interface{} `json:"args"`
	} `json:"processArguments"`
	Name     string `json:"name"`
	Pid      int    `json:"pid"`
	BundleId string `json:"bundleId"`
}

type Build

type Build struct {
	Time                    string `json:"time"`
	ProductBundleIdentifier string `json:"productBundleIdentifier"`
}

type Client

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

Client talks to a WebDriverAgent server.

func New

func New(address string, httpClient *http.Client) *Client

New creates a client of the WebDriverAgent at address. It sends its requests with httpClient; a nil httpClient gets a client without timeout.

func (*Client) AcceptAlert

func (c *Client) AcceptAlert(accept bool) (string, error)

AcceptAlert accepts the visible alert, or dismisses it when accept is false.

func (*Client) ActiveAppInfo

func (c *Client) ActiveAppInfo() (*AppInfo, error)

ActiveAppInfo describes the app in the foreground.

func (*Client) Alive added in v1.1.0

func (c *Client) Alive(timeout time.Duration) bool

Alive reports whether the WebDriverAgent server answers.

func (*Client) CloseSession

func (c *Client) CloseSession() error

CloseSession ends the session of the client.

func (*Client) CreateSession

func (c *Client) CreateSession() (*Session, error)

CreateSession opens a session; later calls of the client belong to it.

func (*Client) Drag added in v1.1.0

func (c *Client) Drag(from, to Point, durationSeconds float64) error

Drag drags from one point to another over duration seconds.

func (*Client) FindElement

func (c *Client) FindElement(by, value string) (*Element, error)

FindElement looks an element up, by is the locator strategy ("name", "class name", …).

func (*Client) GetAlertText

func (c *Client) GetAlertText() (string, error)

GetAlertText returns the text of the visible alert.

func (*Client) GetSettings

func (c *Client) GetSettings() (*Settings, error)

GetSettings reads the Appium settings of the session.

func (*Client) Launch

func (c *Client) Launch(bundleIdentifier string, shouldWaitForQuiescence bool, arguments []string) error

Launch starts the app; arguments are passed to it as launch arguments.

func (*Client) MjpegURL added in v1.1.0

func (c *Client) MjpegURL(port int) (string, error)

MjpegURL is the URL of the MJPEG server on the host of the WebDriverAgent.

func (*Client) PressButton

func (c *Client) PressButton(name string) error

PressButton presses a hardware button: "home", "volumeUp" or "volumeDown".

func (*Client) Screen added in v1.1.0

func (c *Client) Screen() (ScreenInfo, error)

Screen returns the screen size in points and the scale of the device.

func (*Client) ScreenScale added in v1.1.0

func (c *Client) ScreenScale() (float64, error)

ScreenScale returns the ratio between screenshot pixels and WDA points.

func (*Client) Screenshot added in v1.2.0

func (c *Client) Screenshot() ([]byte, error)

Screenshot returns the PNG of the screen.

func (*Client) SendText

func (c *Client) SendText(value string) error

SendText types the text into the focused element, one key per character.

func (*Client) SetSettings

func (c *Client) SetSettings(settings Settings) error

SetSettings writes the Appium settings of the session.

func (*Client) Status

func (c *Client) Status() (*Status, error)

Status asks the server for its state.

func (*Client) Tap added in v1.1.0

func (c *Client) Tap(x, y float64) error

Tap taps at the given point (in WDA points, not pixels).

func (*Client) TapElement

func (c *Client) TapElement(elementId string) error

TapElement clicks the element.

func (*Client) Terminate

func (c *Client) Terminate(bundleIdentifier string) error

Terminate stops the app.

func (*Client) UpdateSettings added in v1.1.0

func (c *Client) UpdateSettings(settings map[string]any) error

UpdateSettings changes Appium settings of the session, e.g. mjpegServerFramerate. WebDriverAgent applies them to the whole runner.

type Element

type Element struct {
	SessionId string        `json:"sessionId"`
	Value     *ElementValue `json:"value"`
}

type ElementButtons

type ElementButtons struct {
	SessionId string   `json:"sessionId"`
	Value     []string `json:"value"`
}

type ElementValue

type ElementValue struct {
	Element string `json:"ELEMENT"`
}

type HTTPError added in v1.2.0

type HTTPError struct {
	Action  string
	Status  int
	Message string
}

HTTPError is the error response of WebDriverAgent.

func (*HTTPError) Error added in v1.2.0

func (e *HTTPError) Error() string

type MjpegReader added in v1.1.0

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

MjpegReader splits a multipart/x-mixed-replace body into JPEG frames.

It doesn't use mime/multipart: WebDriverAgent declares the boundary as "--BoundaryString" but writes "--BoundaryString" as the delimiter, which a strict parser rejects. Parts are found by their Content-Length header; parts without one are read up to the JPEG end marker.

func NewMjpegReader added in v1.1.0

func NewMjpegReader(r io.Reader) *MjpegReader

func (*MjpegReader) ReadFrame added in v1.1.0

func (m *MjpegReader) ReadFrame() ([]byte, error)

ReadFrame returns the next frame. The slice belongs to the caller.

type MjpegStream added in v1.1.0

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

MjpegStream reads the JPEG frames of the WebDriverAgent MJPEG server.

func OpenMjpeg added in v1.1.0

func OpenMjpeg(ctx context.Context, address string) (*MjpegStream, error)

OpenMjpeg connects to an MJPEG server. The stream ends when ctx is done or it is closed.

func (*MjpegStream) Close added in v1.1.0

func (s *MjpegStream) Close() error

func (*MjpegStream) ReadFrame added in v1.1.0

func (s *MjpegStream) ReadFrame() ([]byte, error)

ReadFrame returns the next JPEG frame.

type Point added in v1.2.0

type Point struct{ X, Y float64 }

Point is a position on the screen in WDA points.

type ScreenInfo added in v1.1.0

type ScreenInfo struct {
	// Width and Height are in points, in the current orientation.
	Width  float64
	Height float64
	// Scale is the number of screenshot pixels per point.
	Scale float64
}

ScreenInfo is the answer of /wda/screen.

type Session

type Session struct {
	SessionID string       `json:"sessionId"`
	Value     SessionValue `json:"value"`
}

type SessionValue

type SessionValue struct {
	SessionID    string            `json:"sessionId"`
	Capabilities map[string]string `json:"capabilities"`
}

type SettingValue

type SettingValue struct {
	ShouldUseCompactResponses    bool   `json:"shouldUseCompactResponses"`
	ElementResponseAttributes    string `json:"elementResponseAttributes"`
	MjpegServerScreenshotQuality int    `json:"mjpegServerScreenshotQuality"`
	MjpegServerFramerate         int    `json:"mjpegServerFramerate"`
	MjpegScalingFactor           int    `json:"mjpegScalingFactor"`
	ScreenshotQuality            int    `json:"screenshotQuality"`
	KeyboardAutocorrection       int    `json:"keyboardAutocorrection"`
	KeyboardPrediction           bool   `json:"keyboardPrediction"`
	SnapshotTimeout              int    `json:"snapshotTimeout"`
	CustomSnapshotTimeout        int    `json:"customSnapshotTimeout"`
	SnapshotMaxDepth             int    `json:"snapshotMaxDepth"`
	UseFirstMatch                bool   `json:"useFirstMatch"`
	BoundElementsByIndex         bool   `json:"boundElementsByIndex"`
	ReduceMotion                 bool   `json:"reduceMotion"`
	DefaultActiveApplication     string `json:"defaultActiveApplication"`
	ActiveAppDetectionPoint      string `json:"activeAppDetectionPoint"`
	IncludeNonModalElements      bool   `json:"includeNonModalElements"`
	DefaultAlertAction           string `json:"defaultAlertAction"`
	AcceptAlertButtonSelector    string `json:"acceptAlertButtonSelector"`
	DismissAlertButtonSelector   string `json:"dismissAlertButtonSelector"`
	ScreenshotOrientation        string `json:"screenshotOrientation"`
	WaitForIdleTimeout           int    `json:"waitForIdleTimeout"`
	AnimationCoolOffTimeout      int    `json:"animationCoolOffTimeout"`
}

type Settings

type Settings struct {
	SessionID string                 `json:"sessionId"`
	Value     map[string]interface{} `json:"value"`
}

type Status

type Status struct {
	SessionID string      `json:"sessionId"`
	Value     StatusValue `json:"value"`
}

type StatusValue

type StatusValue struct {
	Message string            `json:"message"`
	State   string            `json:"state"`
	OS      map[string]string `json:"os"`
	IOS     map[string]string `json:"ios"`
	Ready   bool              `json:"ready"`
	Build   Build             `json:"build"`
}

type WDAConnectHook

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

WDAConnectHook picks the WebDriverAgent server URL out of the go-ios log output. go-ios logs the URL without the device id, so startups are serialized through Await: only one device waits for a URL at a time.

The hook only sees the log output once it is registered with a logger, e.g. logrus.AddHook(hook). The zero value is ready to use.

func (*WDAConnectHook) Await added in v1.1.0

func (hook *WDAConnectHook) Await(timeout time.Duration, after func(time.Duration) <-chan time.Time, start func(fail func(error))) (string, error)

Await runs start and waits for the server URL it logs. start calls fail when the runner stops before it reported the URL, which ends the wait. The wait gives up after timeout, measured with after (time.After or a clock's).

func (*WDAConnectHook) Fire

func (hook *WDAConnectHook) Fire(entry *logrus.Entry) error

func (*WDAConnectHook) Levels

func (hook *WDAConnectHook) Levels() []logrus.Level

type WDAError

type WDAError struct {
	Value struct {
		Error     string `json:"error"`
		Message   string `json:"message"`
		Traceback string `json:"traceback"`
	} `json:"value"`
	SessionId string `json:"sessionId"`
}

Jump to

Keyboard shortcuts

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