Documentation
¶
Overview ¶
Ported from browser-use/browser-use@dfb6a73 browser_use/browser/local.py
Ported from browser-use/browser-use@dfb6a73 browser_use/repl/session.py
Ported from browser-use/browser-use@dfb6a73 browser_use/ax.py
Package browsercheck drives headless Chrome through a list of steps and reports one FACTORY_GATES line. ParseSteps reads the YAML step list, Run executes it and stops at the first failing step, and Result.Line renders the gate line. The factory browsercheck command in cmd/factory is the caller.
Index ¶
- Constants
- func CopyProfile(root, dir, dst string) error
- func LookChrome(look func(string) (string, error)) (string, error)
- func NewCommand() *cobra.Command
- func SkipCopy(name string) bool
- func SweepStale(root string, now time.Time)
- type Conditions
- type Options
- type Result
- type Secret
- type Secrets
- type SettleResult
- type Step
Constants ¶
const TempPrefix = "factory-browsercheck-"
TempPrefix starts the name of every temp dir a run makes; SweepStale only touches names with it.
Variables ¶
This section is empty.
Functions ¶
func CopyProfile ¶
CopyProfile copies Local State and one profile directory from a Chrome user-data-dir into dst, without caches, lock files or the other profiles. Symlinks are copied as symlinks.
func LookChrome ¶
LookChrome returns the first Chrome binary found through look, or an error when there is none.
func NewCommand ¶
NewCommand returns `browsercheck`, the command the browser check pack runs. It prints one FACTORY_GATES line and exits non-zero when a step fails or Chrome is missing.
func SweepStale ¶
SweepStale deletes temp dirs left in root by runs that died without cleaning up (SIGKILL, OOM, a crash): a profile copy holds the user's cookies. A dir whose owner still runs stays locked, a dir younger than a minute is skipped, and a dir with no owner file is not ours to judge.
Types ¶
type Conditions ¶
type Conditions struct {
Ready bool // document is not loading
Quiet bool // no DOM mutation or input event for the quiet window
Network bool // no fresh in-flight request and none finished within the quiet window
}
Conditions picks which signals Settle waits for.
type Options ¶
type Options struct {
Steps []Step
OutDir string // screenshots are written here
Look func(string) (string, error) // finds a binary on PATH; os.LookPath when nil
// Profile is a Chrome user-data-dir whose Local State and Default profile are copied, without
// caches, into a temp dir for the run. Empty runs with a fresh profile.
Profile string
Secrets Secrets // values type_secret may type; they never appear in the result
TempRoot string // where the run's temp dir goes; os.TempDir() when empty
}
Options configures Run.
type Result ¶
type Result struct {
Passed int
Failed int
Message string // empty when every step passed, else why the first failing step failed
}
Result is the outcome of one run.
type Secret ¶
type Secret struct {
Name string
Value string
Domain string // when set, the value types only on this host or a subdomain of it
}
Secret is a named value a step may type without the value ever being printed.
type Secrets ¶
type Secrets []Secret
Secrets is the set a run may type from.
func LoadSecrets ¶
LoadSecrets reads a YAML map of name to value, or name to {value, domain}.
func (Secrets) Lookup ¶
Lookup returns the value of the secret called name for a page on host. A scoped secret fails closed when host is empty or outside its domain. Errors name secrets, never values.
type SettleResult ¶
type SettleResult struct {
Why string // "quiet" when every chosen condition held, "cap" when the cap ran out
Took time.Duration
}
SettleResult says why a Settle call returned and how long it took.
func Settle ¶
func Settle(env settleEnv, c Conditions, cap, quiet, since time.Duration) SettleResult
Settle waits on events, never a fixed sleep: the chosen conditions must hold, bounded by cap. While the document loads the bound grows to navCap. since is when the action began, so DOM quiet from before it does not count; zero means now.
type Step ¶
type Step struct {
Kind string // goto, click, fill, type_secret, expect_text, expect_no_console_error or screenshot
URL string // goto target
Selector string // click and fill target
Value string // fill value
Text string // expect_text needle
Name string // screenshot file name without extension, or the secret name for type_secret
}
Step is one parsed browser step.
func ParseSteps ¶
ParseSteps reads a YAML list of single-key step maps and validates each one.