chrome

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithAwaitPromise = func(p *runtime.EvaluateParams) *runtime.EvaluateParams {
	return p.WithAwaitPromise(true)
}

Functions

func NewStreamReader

func NewStreamReader(ctx context.Context, handle cdprotoio.StreamHandle) io.ReadCloser

NewStreamReader creates a new stream reader.

Types

type Instance

type Instance interface {
	NewTab(logger log.Logger, conf config.Config) *Tab
	Name() string
	Close(logger log.Logger)
}

Instance is the interface remote and local chrome must implement.

type LocalInstance

type LocalInstance struct {
	// contains filtered or unexported fields
}

LocalInstance is a locally running browser instance.

func NewLocalBrowserInstance

func NewLocalBrowserInstance(ctx context.Context, logger log.Logger, insecureSkipVerify bool) (*LocalInstance, error)

NewLocalBrowserInstance creates a new local browser instance.

func (*LocalInstance) Close

func (i *LocalInstance) Close(logger log.Logger)

func (*LocalInstance) Name

func (i *LocalInstance) Name() string

Name returns the kind of browser instance.

func (*LocalInstance) NewTab

func (i *LocalInstance) NewTab(_ log.Logger, _ config.Config) *Tab

NewTab starts and returns a new tab on current browser instance.

type PDFOptions

type PDFOptions struct {
	Header string
	Body   string
	Footer string

	Orientation string
}

PDFOptions contains the templated HTML Body, Header and Footer strings.

type RemoteInstance

type RemoteInstance struct {
	// contains filtered or unexported fields
}

RemoteInstance is a remotely running browser instance.

func NewRemoteBrowserInstance

func NewRemoteBrowserInstance(ctx context.Context, _ log.Logger, remoteChromeURL string) (*RemoteInstance, error)

NewRemoteBrowserInstance creates a new remote browser instance.

func (*RemoteInstance) Close

func (i *RemoteInstance) Close(_ log.Logger)

Close releases the resources of browser instance.

func (*RemoteInstance) Name

func (i *RemoteInstance) Name() string

Name returns the kind of browser instance.

func (*RemoteInstance) NewTab

func (i *RemoteInstance) NewTab(logger log.Logger, _ config.Config) *Tab

NewTab starts and returns a new tab on current browser instance.

type Tab

type Tab struct {
	// contains filtered or unexported fields
}

Tab is container for a browser tab.

func (*Tab) Close

func (t *Tab) Close(logger log.Logger)

Close releases the resources of the current browser tab.

func (*Tab) Context

func (t *Tab) Context() context.Context

Context returns the current tab's context.

func (*Tab) NavigateAndWaitFor

func (t *Tab) NavigateAndWaitFor(addr string, headers map[string]any, eventName string) error

NavigateAndWaitFor navigates to the given address and waits for the given event to be fired on the page.

func (*Tab) PrintToPDF

func (t *Tab) PrintToPDF(options PDFOptions, writer io.Writer) error

PrintToPDF returns chroms tasks that print the requested HTML into a PDF and returns the PDF stream handle.

func (*Tab) Run

func (t *Tab) Run(actions ...chromedp.Action) error

Run executes the actions in the current tab.

func (*Tab) RunWithTimeout

func (t *Tab) RunWithTimeout(timeout time.Duration, actions ...chromedp.Action) error

Run executes the actions in the current tab.

func (*Tab) WithTimeout

func (t *Tab) WithTimeout(timeout time.Duration)

WithTimeout set the timeout for the actions in the current tab.

Jump to

Keyboard shortcuts

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