Documentation
¶
Overview ¶
Package flow parses flow files (and Test Buddy's multi-device extension) into commands. Values interpolated at run time (${...}) are kept as raw strings; the engine evaluates them just before each command runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeOrientation ¶
NormalizeOrientation is exported for the engine (run-time values).
Types ¶
type ArgKV ¶
ArgKV is one launch argument; Value keeps its YAML type (string, bool, int64, float64).
type Command ¶
type Command struct {
Name string
File string // file it was written in
Line int
Label string
Optional bool
// LabelInterpolated is false for the few commands whose label the format does not evaluate.
LabelRaw bool
Selector *Selector
// tapOn / doubleTapOn / longPressOn
Point string
Repeat int
Delay int
RetryTapIfNoChange bool
WaitUntilVisible bool
WaitToSettleTimeoutMs int
LongPress bool
// assertTrue / extendedWaitUntil / when
Cond *Condition
Timeout string
// inputText, setClipboard, openLink(link), evalScript(script), setOrientation,
// takeScreenshot/startRecording/assertScreenshot (path), assertWithAI(assertion), pressKey(key)
Text string
// inputRandom*
RandomKind string
Length int
// eraseText
Count int
// swipe
Direction string
Start string
End string
From *Selector
Duration int
// scrollUntilVisible
In *Selector // scrollUntilVisibleIn's list: drag across the list holding this element
Speed string
VisibilityPct int
CenterElement bool
ScrollTimeoutSet bool
// launchApp / stopApp / killApp / clearState / setPermissions
AppID string
ClearState bool
ClearKeychain bool
StopApp *bool
Permissions []KV
Arguments []ArgKV
// openLink
AutoVerify bool
Browser bool
// runFlow / retry / runScript / repeat
SubFile string // absolute
SubFlow *Flow // parsed sub-flow file
Commands []*Command
Env []KV
When *Condition
Script string // runScript source
Times string
While *Condition
MaxRetries string
// takeScreenshot / assertScreenshot
CropOn *Selector
Threshold string
// setLocation / travel
Latitude, Longitude string
Points [][2]float64
TravelSpeed float64
// addMedia
Files []string
// setAirplaneMode / setDarkMode
Enabled bool
// extractTextWithAI
OutputVariable string
// Test Buddy multi-device extension
On string // `on: <role>` with Commands
Parallel map[string][]*Command // `parallel: {role: [commands]}`
ParallelOrder []string
Signal string // `signal: name` / `waitForSignal: name`
}
Command is one flow step. Name is the YAML key; the payload fields used depend on it.
func ParseCommands ¶
ParseCommands parses a YAML list of commands (or a single command) without a config header, as agents send them to `tb do`. dir resolves relative paths.
type Condition ¶
type Condition struct {
Platform string
Visible *Selector
NotVisible *Selector
True *string
Label string
Timeout string // extension: ms to wait for visible/notVisible
}
Condition is a `when` / `while` / assertion condition.
type Config ¶
type Config struct {
AppID string // the app to drive; a web flow's url: (which wins over appId)
URL string // the header's url:, raw (may hold ${...}); set means a web flow
Name string
Tags []string
Env []KV
OnFlowStart []*Command
OnFlowComplete []*Command
Properties map[string]string
PropertyOrder []string
Ext map[string]any
// Test Buddy multi-device extension: named device roles. Empty for single-device flows.
Devices []*DeviceRole
}
Config is the flow's header document.
type DeviceRole ¶
type DeviceRole struct {
Name string
Platform string // "android", "ios" or "" (any)
Device string // serial, UDID or device name; "" = any free device
AppID string
Env []KV
}
DeviceRole is one device a multi-device flow drives.
type Flow ¶
type Flow struct {
Path string // absolute path ("" for inline flows)
Dir string // directory relative paths resolve against
Config Config
Commands []*Command
}
Flow is one parsed flow file.
func ParseBytes ¶
ParseBytes parses flow text as if it were the file at path (used for relative paths).
type Selector ¶
type Selector struct {
Text string
ID string
Index string
CSS string
Width, Height, Tolerance *int
Enabled, Selected *bool
Checked, Focused *bool
Traits []string
Below, Above, LeftOf, RightOf *Selector
ContainsChild, ChildOf *Selector
ContainsDescendants []*Selector
Optional bool // selector-level optional (makes the command optional, no shorter timeout)
}
Selector is the flow format's element selector. String fields may hold ${...}.
func (*Selector) HasCriteria ¶
HasCriteria reports whether any filtering key is set.