Documentation
¶
Index ¶
- Constants
- func ParseServerURL(line string) (string, bool)
- type AppInfo
- type AppInfoValue
- type Build
- type Client
- func (c *Client) AcceptAlert(accept bool) (string, error)
- func (c *Client) ActiveAppInfo() (*AppInfo, error)
- func (c *Client) Alive(timeout time.Duration) bool
- func (c *Client) CloseSession() error
- func (c *Client) CreateSession() (*Session, error)
- func (c *Client) Drag(from, to Point, durationSeconds float64) error
- func (c *Client) FindElement(by, value string) (*Element, error)
- func (c *Client) GetAlertText() (string, error)
- func (c *Client) GetSettings() (*Settings, error)
- func (c *Client) Launch(bundleIdentifier string, shouldWaitForQuiescence bool, arguments []string) error
- func (c *Client) MjpegURL(port int) (string, error)
- func (c *Client) PressButton(name string) error
- func (c *Client) Screen() (ScreenInfo, error)
- func (c *Client) ScreenScale() (float64, error)
- func (c *Client) Screenshot() ([]byte, error)
- func (c *Client) SendText(value string) error
- func (c *Client) SetSettings(settings Settings) error
- func (c *Client) Status() (*Status, error)
- func (c *Client) Tap(x, y float64) error
- func (c *Client) TapElement(elementId string) error
- func (c *Client) Terminate(bundleIdentifier string) error
- func (c *Client) UpdateSettings(settings map[string]any) error
- type Element
- type ElementButtons
- type ElementValue
- type HTTPError
- type MjpegReader
- type MjpegStream
- type Point
- type ScreenInfo
- type Session
- type SessionValue
- type SettingValue
- type Settings
- type Status
- type StatusValue
- type WDAConnectHook
- type WDAError
Constants ¶
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
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 Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a WebDriverAgent server.
func New ¶
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 ¶
AcceptAlert accepts the visible alert, or dismisses it when accept is false.
func (*Client) ActiveAppInfo ¶
ActiveAppInfo describes the app in the foreground.
func (*Client) CloseSession ¶
CloseSession ends the session of the client.
func (*Client) CreateSession ¶
CreateSession opens a session; later calls of the client belong to it.
func (*Client) FindElement ¶
FindElement looks an element up, by is the locator strategy ("name", "class name", …).
func (*Client) GetAlertText ¶
GetAlertText returns the text of the visible alert.
func (*Client) GetSettings ¶
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
MjpegURL is the URL of the MJPEG server on the host of the WebDriverAgent.
func (*Client) PressButton ¶
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
ScreenScale returns the ratio between screenshot pixels and WDA points.
func (*Client) Screenshot ¶ added in v1.2.0
Screenshot returns the PNG of the screen.
func (*Client) SetSettings ¶
SetSettings writes the Appium settings of the session.
func (*Client) TapElement ¶
TapElement clicks the element.
type Element ¶
type Element struct {
SessionId string `json:"sessionId"`
Value *ElementValue `json:"value"`
}
type ElementButtons ¶
type ElementValue ¶
type ElementValue struct {
Element string `json:"ELEMENT"`
}
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 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 Status ¶
type Status struct {
SessionID string `json:"sessionId"`
Value StatusValue `json:"value"`
}
type StatusValue ¶
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) Levels ¶
func (hook *WDAConnectHook) Levels() []logrus.Level