flow

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 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

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

func NormalizeOrientation(s string) string

NormalizeOrientation is exported for the engine (run-time values).

Types

type ArgKV

type ArgKV struct {
	Key   string
	Value any
}

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

func ParseCommands(dir string, data []byte) ([]*Command, error)

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.

func (*Command) Mutating

func (c *Command) Mutating() bool

Mutating reports whether the command counts as a device interaction for the lookup-timeout clock (lookups after a recent interaction get a shorter timeout).

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.

func (*Config) Ignored added in v0.4.0

func (c *Config) Ignored() []string

Ignored are notes on the header keys tb accepts but does not act on.

func (*Config) Web

func (c *Config) Web() bool

Web reports whether the header used url:, which makes this a web flow whatever the value turns out to be once ${...} is resolved.

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 Error

type Error struct {
	File string
	Line int
	Msg  string
}

Error is a flow syntax error with its location.

func (*Error) Error

func (e *Error) Error() string

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

func ParseBytes(path string, data []byte) (*Flow, error)

ParseBytes parses flow text as if it were the file at path (used for relative paths).

func ParseFile

func ParseFile(path string) (*Flow, error)

ParseFile parses a flow file and every sub-flow it references.

func (*Flow) Name

func (f *Flow) Name() string

Name is the flow's display name: config name, else the file name without extension.

type KV

type KV struct {
	Key   string
	Value string
}

KV is an ordered key/value pair (env blocks evaluate in order).

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

func (s *Selector) HasCriteria() bool

HasCriteria reports whether any filtering key is set.

Jump to

Keyboard shortcuts

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