Documentation
¶
Index ¶
- func Params() []string
- func Request(data map[string]any, opts ...Option) (map[string]any, error)
- func Serve()
- type Action
- type BrowserRunner
- type Callback
- type ChromeDPAction
- type ChromeDPRunner
- type MockRunner
- func (m *MockRunner) GetAllCalls() [][]chromedp.Action[chromedp.Void]
- func (m *MockRunner) GetCallCount() int
- func (m *MockRunner) GetLastCall() []chromedp.Action[chromedp.Void]
- func (m *MockRunner) Run(ctx context.Context, actions ...chromedp.Action[chromedp.Void]) error
- func (m *MockRunner) SetRunFunc(fn func(ctx context.Context, actions ...chromedp.Action[chromedp.Void]) error)
- func (m *MockRunner) Start(ctx context.Context) error
- type Option
- type Req
- type Res
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Params ¶ added in v1.20.0
func Params() []string
Params returns the keys the browser action takes in with: those of Req, and timeout, which it reads apart from Req.
Types ¶
type BrowserRunner ¶ added in v1.18.0
type BrowserRunner interface {
// Start launches the browser. chromedp ties the browser process to the
// context of the first Run, so the browser is started on a context
// without the actions' deadline and outlives a timed-out action.
Start(ctx context.Context) error
Run(ctx context.Context, actions ...chromedp.Action[chromedp.Void]) error
}
BrowserRunner defines the interface for running browser actions
type ChromeDPAction ¶ added in v1.18.0
type ChromeDPAction struct {
ID string `map:"id"`
Name string `map:"name"`
URL string `map:"url"`
Selector string `map:"selector"`
Attribute []string `map:"attribute"`
Value string `map:"value"`
Path string `map:"path"` // Deprecated: use FilePath from results
Quality int `map:"quality"`
// contains filtered or unexported fields
}
func NewChromeDPAction ¶ added in v1.18.0
func NewChromeDPAction() *ChromeDPAction
type ChromeDPRunner ¶ added in v1.18.0
type ChromeDPRunner struct{}
ChromeDPRunner implements BrowserRunner using the actual ChromeDP
type MockRunner ¶ added in v1.18.0
type MockRunner struct {
RunFunc func(ctx context.Context, actions ...chromedp.Action[chromedp.Void]) error
CallHistory [][]chromedp.Action[chromedp.Void]
// contains filtered or unexported fields
}
MockRunner implements BrowserRunner for testing
func NewMockRunner ¶ added in v1.18.0
func NewMockRunner() *MockRunner
NewMockRunner creates a new mock browser runner
func (*MockRunner) GetAllCalls ¶ added in v1.18.0
func (m *MockRunner) GetAllCalls() [][]chromedp.Action[chromedp.Void]
GetAllCalls returns all recorded Run calls
func (*MockRunner) GetCallCount ¶ added in v1.18.0
func (m *MockRunner) GetCallCount() int
GetCallCount returns the number of Run calls made
func (*MockRunner) GetLastCall ¶ added in v1.18.0
func (m *MockRunner) GetLastCall() []chromedp.Action[chromedp.Void]
GetLastCall returns the actions from the most recent Run call
func (*MockRunner) Run ¶ added in v1.18.0
Run records the call and optionally executes a custom function
func (*MockRunner) SetRunFunc ¶ added in v1.18.0
func (m *MockRunner) SetRunFunc(fn func(ctx context.Context, actions ...chromedp.Action[chromedp.Void]) error)
SetRunFunc sets a custom function to execute when Run is called
type Option ¶ added in v1.18.0
type Option func(*Callback)
func WithBefore ¶ added in v1.18.0
func WithInBrowser ¶ added in v1.18.0
type Req ¶ added in v1.18.0
type Req struct {
Actions []*ChromeDPAction `map:"actions"`
Headless bool `map:"headless"`
WindowW int `map:"window_w"`
WindowH int `map:"window_h"`
// EvidenceDir is where the page is saved when the actions fail. Empty
// means the system's temporary directory.
EvidenceDir string `map:"evidence_dir"`
Timeout time.Duration
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.