Documentation
¶
Overview ¶
Package desktop gives a target a private graphical display the operator can watch from a browser.
A tool that drives a real browser — a recorded replay, a test in headed mode, an agent clicking through a page — has nowhere to draw on a headless server, and what it would draw is exactly what the operator wants to see. This starts a virtual display with a VNC server and a noVNC web client on the target, all bound to the target's loopback. The control plane reaches the web client with a port forward, so nothing new listens on the target's network.
A browser running inside that display sees the target's own localhost, which is also the simplest way to use a web app that only listens there.
Index ¶
- Variables
- func A11yAct(ctx context.Context, run Runner, d *Desktop, ref int, action, text string) (string, error)
- func A11ySnapshot(ctx context.Context, run Runner, d *Desktop) (string, int, error)
- func Act(ctx context.Context, run Runner, d *Desktop, a Action) error
- func KeepAlive(ctx context.Context, run Runner, dirs ...string) error
- func OpenBrowser(ctx context.Context, run Runner, d *Desktop, address string) (string, error)
- func Screenshot(ctx context.Context, run Runner, d *Desktop) ([]byte, error)
- func Stop(ctx context.Context, run Runner, dir string) error
- type Action
- type Desktop
- type MissingError
- type Runner
- type Window
Constants ¶
This section is empty.
Variables ¶
var ErrNoA11y = fmt.Errorf("this desktop has no accessibility bus (install at-spi2-core, dbus and x11-utils " +
"on its machine, then start a new desktop); coordinates still work")
ErrNoA11y means the desktop has no accessibility bus to read.
Functions ¶
func A11yAct ¶ added in v2.6.0
func A11yAct(ctx context.Context, run Runner, d *Desktop, ref int, action, text string) (string, error)
A11yAct clicks, focuses or types into the element ref names. It uses the element's own accessible action where it has one, and otherwise clicks the middle of its rectangle; via says which happened.
func A11ySnapshot ¶ added in v2.6.0
A11ySnapshot reads the desktop's accessibility tree: every app, window and control, each actionable one with a [ref=N] and its screen rectangle.
func KeepAlive ¶ added in v2.6.0
KeepAlive tells other servers on the machine these desktops are still in use; Start reaps one whose owner stopped doing this.
func OpenBrowser ¶
OpenBrowser starts a browser inside the desktop at address and names the one it found. A target with no browser still has a working desktop: a tool that brings its own, as Playwright does, only needs DISPLAY.
func Screenshot ¶ added in v2.6.0
Screenshot captures the whole display as PNG, with whichever capture tool the machine has.
Types ¶
type Action ¶ added in v2.6.0
type Action struct {
Type string `json:"action"` // click|double_click|right_click|move|type|key|scroll
X int `json:"x"`
Y int `json:"y"`
Text string `json:"text"`
Key string `json:"key"`
Scroll string `json:"direction"` // up|down|left|right
Amount int `json:"amount"`
}
Action is one input to a desktop.
type Desktop ¶
type Desktop struct {
Dir string // private state on the target: pids, logs, the browser profile
Display int // the X display number: tools run with DISPLAY=:<Display>
Port int // the noVNC web client, on the target's loopback
Width int
Height int
}
Desktop is one running display.
type MissingError ¶
type MissingError struct{ Tools []string }
MissingError names what the target needs installed before it can do this.
func (*MissingError) Error ¶
func (e *MissingError) Error() string