Documentation ¶
Index ¶
- Constants
- Variables
- func CACert(path string) grpcRunnerOption
- func CACertFromData(b []byte) grpcRunnerOption
- func Cert(path string) grpcRunnerOption
- func CertFromData(b []byte) grpcRunnerOption
- func CreateHTTPStepMapSlice(key string, req *http.Request) (yaml.MapSlice, error)
- func GetDesc(opt Option) (string, error)
- func Key(path string) grpcRunnerOption
- func KeyFromData(b []byte) grpcRunnerOption
- func Load(pathp string, opts ...Option) (*operators, error)
- func LoadBook(path string) (*book, error)
- func LoadRunbook(in io.Reader) (*runbook, error)
- func New(opts ...Option) (*operator, error)
- func NewCmdOut(out io.Writer) *cmdOut
- func NewDebugger(out io.Writer) *debugger
- func NewRunbook(desc string) *runbook
- func NotFollowRedirect(nf bool) httpRunnerOption
- func OpenApi3(l string) httpRunnerOption
- func OpenApi3FromData(d []byte) httpRunnerOption
- func Paths(pathp string) ([]string, error)
- func ShortenPath(p string) string
- func SkipValidateRequest(skip bool) httpRunnerOption
- func SkipValidateResponse(skip bool) httpRunnerOption
- func TLS(useTLS bool) grpcRunnerOption
- type CDPAction
- type CDPActions
- type CDPArgType
- type CDPFn
- type CDPFnArg
- type CDPFnArgs
- type Capturer
- type DBResponse
- type GRPCOp
- type GRPCType
- type ID
- type IDType
- type IDs
- type Loop
- type Option
- func AfterFunc(fn func() error) Option
- func BeforeFunc(fn func() error) Option
- func Book(path string) Option
- func Books(pathp string) ([]Option, error)
- func Capture(c Capturer) Option
- func DBRunner(name string, client Querier) Option
- func Debug(debug bool) Option
- func Desc(desc string) Option
- func FailFast(enable bool) Option
- func Func(k string, v interface{}) Option
- func GRPCNoTLS(noTLS bool) Option
- func GrpcRunner(name string, cc *grpc.ClientConn, opts ...grpcRunnerOption) Option
- func HTTPRunner(name, endpoint string, client *http.Client, opts ...httpRunnerOption) Option
- func HTTPRunnerWithHandler(name string, h http.Handler, opts ...httpRunnerOption) Option
- func Interval(d time.Duration) Option
- func Overlay(path string) Option
- func Profile(profile bool) Option
- func RunMatch(m string) Option
- func RunParallel(enable bool, max int64) Option
- func RunRandom(n int) Option
- func RunSample(n int) Option
- func RunShard(n, i int) Option
- func RunShuffle(enable bool, seed int64) Option
- func Runner(name, dsn string, opts ...httpRunnerOption) Option
- func SkipIncluded(enable bool) Option
- func SkipTest(enable bool) Option
- func T(t *testing.T) Option
- func Underlay(path string) Option
- func Var(k interface{}, v interface{}) Option
- type Querier
- type RunnerType
- type TxQuerier
- type UnsupportedError
Constants ¶
const ( MediaTypeApplicationJSON = "application/json" MediaTypeTextPlain = "text/plain" MediaTypeApplicationFormUrlencoded = "application/x-www-form-urlencoded" )
Variables ¶
var ( AsTestHelper = T Runbook = Book RunPart = RunShard )
var CDPFnMap = map[string]CDPFn{ "navigate": { Desc: "Navigate the current frame to `url` page.", Fn: chromedp.Navigate, Args: CDPFnArgs{ {CDPArgTypeArg, "url", "https://pkg.go.dev/time"}, }, }, "click": { Desc: "Send a mouse click event to the first element node matching the selector (`sel`).", Fn: chromedp.Click, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "nav > div > a"}, }, }, "doubleClick": { Desc: "Send a mouse double click event to the first element node matching the selector (`sel`).", Fn: chromedp.DoubleClick, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "nav > div > li"}, }, }, "sendKeys": { Desc: "Send keys (`value`) to the first element node matching the selector (`sel`).", Fn: chromedp.SendKeys, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "input[name=username]"}, {CDPArgTypeArg, "value", "k1lowxb@gmail.com"}, }, }, "submit": { Desc: "Submit the parent form of the first element node matching the selector (`sel`).", Fn: chromedp.Submit, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "form.login"}, }, }, "scroll": { Desc: "Scroll the window to the first element node matching the selector (`sel`).", Fn: chromedp.ScrollIntoView, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "body > footer"}, }, Aliases: []string{"scrollIntoView"}, }, "wait": { Desc: "Wait for the specified `time`.", Fn: func(d string) chromedp.Action { return &waitAction{d: d} }, Args: CDPFnArgs{ {CDPArgTypeArg, "time", "10sec"}, }, Aliases: []string{"sleep"}, }, "waitReady": { Desc: "Wait until the element matching the selector (`sel`) is ready.", Fn: chromedp.WaitReady, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "body > footer"}, }, }, "waitVisible": { Desc: "Wait until the element matching the selector (`sel`) is visible.", Fn: chromedp.WaitVisible, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "body > footer"}, }, }, "text": { Desc: "Get the visible text of the first element node matching the selector (`sel`).", Fn: chromedp.Text, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "h1"}, {CDPArgTypeRes, "text", "Install the latest version of Go"}, }, Aliases: []string{"getText"}, }, "textContent": { Desc: "Get the text content of the first element node matching the selector (`sel`).", Fn: chromedp.TextContent, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "h1"}, {CDPArgTypeRes, "text", "Install the latest version of Go"}, }, Aliases: []string{"getTextContent"}, }, "innerHTML": { Desc: "Get the inner html of the first element node matching the selector (`sel`).", Fn: chromedp.InnerHTML, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "h1"}, {CDPArgTypeRes, "html", "Install the latest version of Go"}, }, Aliases: []string{"getInnerHTML"}, }, "outerHTML": { Desc: "Get the outer html of the first element node matching the selector (`sel`).", Fn: chromedp.OuterHTML, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "h1"}, {CDPArgTypeRes, "html", "<h1>Install the latest version of Go</h1>"}, }, Aliases: []string{"getOuterHTML"}, }, "fullHTML": { Desc: "Get the full html of page.", Fn: func(html *string) chromedp.Action { expr := "new XMLSerializer().serializeToString(document);" return chromedp.Evaluate(expr, html) }, Args: CDPFnArgs{ {CDPArgTypeRes, "html", "<!DOCTYPE html><html><body><h1>hello</h1></body></html>"}, }, Aliases: []string{"getFullHTML", "getHTML", "html"}, }, "value": { Desc: "Get the Javascript value field of the first element node matching the selector (`sel`).", Fn: chromedp.Value, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "input[name=address]"}, {CDPArgTypeRes, "value", "Fukuoka"}, }, Aliases: []string{"getValue"}, }, "setUploadFile": { Desc: "Set upload file (`path`) to the first element node matching the selector (`sel`).", Fn: func(sel, path string) chromedp.Action { abs, err := filepath.Abs(path) if err != nil { return &errAction{err: err} } if _, err := os.Stat(abs); err != nil { return &errAction{err: err} } return chromedp.SetUploadFiles(sel, []string{abs}) }, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "input[name=avator]"}, {CDPArgTypeArg, "path", "/path/to/image.png"}, }, Aliases: []string{"setUpload"}, }, "title": { Desc: "Get the document `title`.", Fn: chromedp.Title, Args: CDPFnArgs{ {CDPArgTypeRes, "title", "GitHub"}, }, Aliases: []string{"getTitle"}, }, "location": { Desc: "Get the document location.", Fn: chromedp.Location, Args: CDPFnArgs{ {CDPArgTypeRes, "url", "https://github.com"}, }, Aliases: []string{"getLocation"}, }, "attributes": { Desc: "Get the element attributes for the first element node matching the selector (`sel`).", Fn: chromedp.Attributes, Args: CDPFnArgs{ {CDPArgTypeArg, "sel", "h1"}, {CDPArgTypeRes, "attrs", `{"class": "sr-only"}`}, }, Aliases: []string{"getAttributes", "attrs", "getAttrs"}, }, "screenshot": { Desc: "Take a full screenshot of the entire browser viewport.", Fn: func(b *[]byte) chromedp.Action { return chromedp.FullScreenshot(b, 100) }, Args: CDPFnArgs{ {CDPArgTypeRes, "png", "[]byte"}, }, Aliases: []string{"getScreenshot"}, }, "evaluate": { Desc: "Evaluate the Javascript expression (`expr`).", Fn: func(expr string) chromedp.Action { return chromedp.Evaluate(expr, nil) }, Args: CDPFnArgs{ {CDPArgTypeArg, "expr", `document.querySelector("h1").textContent = "hello"`}, }, Aliases: []string{"eval"}, }, }
Functions ¶
func CACertFromData ¶ added in v0.26.0
func CACertFromData(b []byte) grpcRunnerOption
func CertFromData ¶ added in v0.26.0
func CertFromData(b []byte) grpcRunnerOption
func CreateHTTPStepMapSlice ¶ added in v0.40.0
func KeyFromData ¶ added in v0.26.0
func KeyFromData(b []byte) grpcRunnerOption
func LoadRunbook ¶ added in v0.42.0
func NewDebugger ¶ added in v0.33.0
func NewRunbook ¶ added in v0.40.0
func NewRunbook(desc string) *runbook
func NotFollowRedirect ¶ added in v0.38.0
func NotFollowRedirect(nf bool) httpRunnerOption
func OpenApi3FromData ¶ added in v0.13.0
func OpenApi3FromData(d []byte) httpRunnerOption
func ShortenPath ¶ added in v0.45.0
func SkipValidateRequest ¶ added in v0.13.0
func SkipValidateRequest(skip bool) httpRunnerOption
func SkipValidateResponse ¶ added in v0.13.0
func SkipValidateResponse(skip bool) httpRunnerOption
Types ¶
type CDPActions ¶ added in v0.47.0
type CDPActions []CDPAction
type CDPArgType ¶ added in v0.47.0
type CDPArgType string
const ( CDPArgTypeArg CDPArgType = "arg" CDPArgTypeRes CDPArgType = "res" )
type CDPFnArg ¶ added in v0.47.0
type CDPFnArg struct { Typ CDPArgType Key string Example string }
type Capturer ¶ added in v0.33.0
type Capturer interface { CaptureStart(ids IDs, bookPath, desc string) CaptureFailed(ids IDs, bookPath, desc string, err error) CaptureSkipped(ids IDs, bookPath, desc string) CaptureSuccess(ids IDs, bookPath, desc string) CaptureEnd(ids IDs, bookPath, desc string) CaptureHTTPRequest(name string, req *http.Request) CaptureHTTPResponse(name string, res *http.Response) CaptureGRPCStart(name string, typ GRPCType, service, method string) CaptureGRPCRequestHeaders(h map[string][]string) CaptureGRPCRequestMessage(m map[string]interface{}) CaptureGRPCResponseStatus(status int) CaptureGRPCResponseHeaders(h map[string][]string) CaptureGRPCResponseMessage(m map[string]interface{}) CaptureGRPCResponseTrailers(t map[string][]string) CaptureGRPCClientClose() CaptureGRPCEnd(name string, typ GRPCType, service, method string) CaptureCDPStart(name string) CaptureCDPAction(a CDPAction) CaptureCDPResponse(a CDPAction, res map[string]interface{}) CaptureCDPEnd(name string) CaptureDBStatement(name string, stmt string) CaptureDBResponse(name string, res *DBResponse) CaptureExecCommand(command string) CaptureExecStdin(stdin string) CaptureExecStdout(stdin string) CaptureExecStderr(stderr string) SetCurrentIDs(ids IDs) Errs() error }
type DBResponse ¶ added in v0.33.0
type ID ¶ added in v0.45.0
type ID struct { Type IDType `json:"type"` Desc string `json:"desc,omitempty"` RunbookID string `json:"id,omitempty"` RunbookPath string `json:"path,omitempty"` StepKey string `json:"key,omitempty"` StepRunnerType RunnerType `json:"runner_type,omitempty"` StepRunnerKey string `json:"runner_key,omitempty"` FuncIndex int `json:"func_index,omitempty"` }
ID - ID and context of each element in the runbook
type Loop ¶ added in v0.29.0
type Loop struct { Count string `yaml:"count,omitempty"` Interval string `yaml:"interval,omitempty"` MinInterval string `yaml:"minInterval,omitempty"` MaxInterval string `yaml:"maxInterval,omitempty"` Jitter *float64 `yaml:"jitter,omitempty"` Multiplier *float64 `yaml:"multiplier,omitempty"` Until string `yaml:"until"` // contains filtered or unexported fields }
type Option ¶
type Option func(*book) error
func AfterFunc ¶ added in v0.20.0
AfterFunc - Register the function to be run after the runbook is run.
func BeforeFunc ¶ added in v0.20.0
BeforeFunc - Register the function to be run before the runbook is run.
func GrpcRunner ¶ added in v0.24.0
func GrpcRunner(name string, cc *grpc.ClientConn, opts ...grpcRunnerOption) Option
GrpcRunner - Set grpc runner to runbook
func HTTPRunner ¶
HTTPRunner - Set http runner to runbook
func HTTPRunnerWithHandler ¶ added in v0.6.0
HTTPRunnerWithHandler - Set http runner to runbook with http.Handler
func RunParallel ¶ added in v0.39.0
RunParallel - Parallelize runs of runbooks.
func RunRandom ¶ added in v0.46.0
RunRandom - Run the specified number of runbooks at random. Sometimes the same runbook is run multiple times.
func RunShard ¶ added in v0.23.0
RunShard - Distribute runbooks into a specified number of shards and run the specified shard of them.
func RunShuffle ¶ added in v0.39.0
RunShuffle - Randomize the order of running runbooks.
func SkipIncluded ¶ added in v0.19.0
SkipIncluded - Skip running the included step by itself.
type RunnerType ¶ added in v0.45.0
type RunnerType string
const ( RunnerTypeHTTP RunnerType = "http" RunnerTypeDB RunnerType = "db" RunnerTypeGRPC RunnerType = "grpc" RunnerTypeCDP RunnerType = "cdp" RunnerTypeExec RunnerType = "exec" RunnerTypeTest RunnerType = "test" RunnerTypeDump RunnerType = "dump" RunnerTypeInclude RunnerType = "include" RunnerTypeBind RunnerType = "bind" )
type UnsupportedError ¶ added in v0.17.1
type UnsupportedError struct {
Cause error
}
func (*UnsupportedError) Error ¶ added in v0.17.1
func (e *UnsupportedError) Error() string
func (UnsupportedError) Unwrap ¶ added in v0.17.1
func (e UnsupportedError) Unwrap() error