common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: AGPL-3.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BrowserStateOpen int64 = iota
	BrowserStateClosing
	BrowserStateClosed
)
View Source
const (
	DefaultLocale       string        = "en-US"
	DefaultScreenWidth  int64         = 1280
	DefaultScreenHeight int64         = 720
	DefaultTimeout      time.Duration = 30 * time.Second

	LifeCycleNetworkIdleTimeout time.Duration = 500 * time.Millisecond
)
View Source
const (
	EventBrowserDisconnected string = "disconnected"

	EventBrowserContextClose string = "close"
	EventBrowserContextPage  string = "page"

	EventConnectionClose string = "close"

	EventFrameNavigation      string = "navigation"
	EventFrameAddLifecycle    string = "addlifecycle"
	EventFrameRemoveLifecycle string = "removelifecycle"

	EventPageClose            string = "close"
	EventPageConsole          string = "console"
	EventPageCrash            string = "crash"
	EventPageDialog           string = "dialog"
	EventPageDOMContentLoaded string = "domcontentloaded"
	EventPageDownload         string = "download"
	EventPageFilechooser      string = "filechooser"
	EventPageFrameAttached    string = "frameattached"
	EventPageFrameDetached    string = "framedetached"
	EventPageFrameNavigated   string = "framenavigated"
	EventPageLoad             string = "load"
	EventPageError            string = "pageerror"
	EventPagePopup            string = "popup"
	EventPageRequest          string = "request"
	EventPageRequestFailed    string = "requestfailed"
	EventPageRequestFinished  string = "requestfinished"
	EventPageResponse         string = "response"
	EventPageWebSocket        string = "websocket"
	EventPageWorker           string = "worker"

	EventSessionClosed string = "close"

	EventWorkerClose string = "close"
)
View Source
const (
	ModifierKeyAlt int64 = 1 << iota
	ModifierKeyControl
	ModifierKeyMeta
	ModifierKeyShift
)

Variables

This section is empty.

Functions

func GetDevices

func GetDevices() map[string]Device

GetDevices returns predefined emulation settings for many end-user devices.

func NewJSHandle

func NewJSHandle(
	ctx context.Context,
	s session,
	ectx *ExecutionContext,
	f *Frame,
	ro *runtime.RemoteObject,
	l *log.Logger,
) jsHandle

NewJSHandle creates a new JS handle referencing a remote object.

func TrimQuotes added in v0.2.0

func TrimQuotes(s string) string

TrimQuotes removes surrounding single or double quotes from s. We're not using strings.Trim() to avoid trimming unbalanced values, e.g. `"'arg` shouldn't change. Source: https://stackoverflow.com/a/48451906

func WithHooks

func WithHooks(ctx context.Context, hooks *Hooks) context.Context

func WithLaunchOptions

func WithLaunchOptions(ctx context.Context, opts *LaunchOptions) context.Context

Types

type Action

type Action interface {
	Do(context.Context) error
}

Action is the general interface of an CDP action.

type ActionFunc

type ActionFunc func(context.Context) error

ActionFunc is an adapter to allow regular functions to be used as an Action.

func (ActionFunc) Do

func (f ActionFunc) Do(ctx context.Context) error

Do executes the func f using the provided context.

type Barrier

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

func NewBarrier

func NewBarrier() *Barrier

func (*Barrier) AddFrameNavigation

func (b *Barrier) AddFrameNavigation(frame *Frame)

func (*Barrier) Wait

func (b *Barrier) Wait(ctx context.Context) error

type BaseEventEmitter

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

BaseEventEmitter emits events to registered handlers.

func NewBaseEventEmitter

func NewBaseEventEmitter(ctx context.Context) BaseEventEmitter

NewBaseEventEmitter creates a new instance of a base event emitter.

type BaseJSHandle

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

BaseJSHandle represents a JS object in an execution context.

func (*BaseJSHandle) AsElement

func (h *BaseJSHandle) AsElement() api.ElementHandle

AsElement returns an element handle if this JSHandle is a reference to a JS HTML element.

func (*BaseJSHandle) Dispose

func (h *BaseJSHandle) Dispose()

Dispose releases the remote object.

func (*BaseJSHandle) Evaluate

func (h *BaseJSHandle) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}

Evaluate will evaluate provided page function within an execution context.

func (*BaseJSHandle) EvaluateHandle

func (h *BaseJSHandle) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) api.JSHandle

EvaluateHandle will evaluate provided page function within an execution context.

func (*BaseJSHandle) GetProperties

func (h *BaseJSHandle) GetProperties() map[string]api.JSHandle

GetProperties retreives the JS handle's properties.

func (*BaseJSHandle) GetProperty

func (h *BaseJSHandle) GetProperty(propertyName string) api.JSHandle

GetProperty retreves a single property of the JS handle.

func (*BaseJSHandle) JSONValue

func (h *BaseJSHandle) JSONValue() goja.Value

JSONValue returns a JSON version of this JS handle.

func (*BaseJSHandle) ObjectID added in v0.3.0

func (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID

ObjectID returns the remote object ID.

type BigIntParseError

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

func (BigIntParseError) Error

func (e BigIntParseError) Error() string

Error satisfies the builtin error interface.

func (BigIntParseError) Is

func (e BigIntParseError) Is(target error) bool

Is satisfies the builtin error Is interface.

func (BigIntParseError) Unwrap

func (e BigIntParseError) Unwrap() error

Unwrap satisfies the builtin error Unwrap interface.

type Browser

type Browser struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

Browser stores a Browser context.

func NewBrowser

func NewBrowser(
	ctx context.Context,
	cancel context.CancelFunc,
	browserProc *BrowserProcess,
	launchOpts *LaunchOptions,
	logger *log.Logger,
) (*Browser, error)

NewBrowser creates a new browser, connects to it, then returns it.

func (*Browser) Close

func (b *Browser) Close()

Close shuts down the browser.

func (*Browser) Contexts

func (b *Browser) Contexts() []api.BrowserContext

Contexts returns list of browser contexts.

func (*Browser) IsConnected

func (b *Browser) IsConnected() bool

IsConnected returns whether the WebSocket connection to the browser process is active or not.

func (*Browser) NewContext

func (b *Browser) NewContext(opts goja.Value) api.BrowserContext

NewContext creates a new incognito-like browser context.

func (*Browser) NewPage

func (b *Browser) NewPage(opts goja.Value) api.Page

NewPage creates a new tab in the browser window.

func (*Browser) On added in v0.3.0

func (b *Browser) On(event string) *goja.Promise

On returns a Promise that is resolved when the browser process is disconnected. The only accepted event value is "disconnected".

func (*Browser) UserAgent

func (b *Browser) UserAgent() string

UserAgent returns the controlled browser's user agent string.

func (*Browser) Version

func (b *Browser) Version() string

Version returns the controlled browser's version.

type BrowserContext

type BrowserContext struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

BrowserContext stores context information for a single independent browser session. A newly launched browser instance contains a default browser context. Any browser context created aside from the default will be considered an "incognito" browser context and will not store any data on disk.

func NewBrowserContext

func NewBrowserContext(
	ctx context.Context, browser *Browser, id cdp.BrowserContextID, opts *BrowserContextOptions, logger *log.Logger,
) *BrowserContext

NewBrowserContext creates a new browser context.

func (*BrowserContext) AddCookies

func (b *BrowserContext) AddCookies(cookies goja.Value)

func (*BrowserContext) AddInitScript

func (b *BrowserContext) AddInitScript(script goja.Value, arg goja.Value)

AddInitScript adds a script that will be initialized on all new pages.

func (*BrowserContext) Browser

func (b *BrowserContext) Browser() api.Browser

Browser returns the browser instance that this browser context belongs to.

func (*BrowserContext) ClearCookies

func (b *BrowserContext) ClearCookies()

ClearCookies clears cookies.

func (*BrowserContext) ClearPermissions

func (b *BrowserContext) ClearPermissions()

ClearPermissions clears any permission overrides.

func (*BrowserContext) Close

func (b *BrowserContext) Close()

Close shuts down the browser context.

func (*BrowserContext) Cookies

func (b *BrowserContext) Cookies() []goja.Object

func (*BrowserContext) ExposeBinding

func (b *BrowserContext) ExposeBinding(name string, callback goja.Callable, opts goja.Value)

func (*BrowserContext) ExposeFunction

func (b *BrowserContext) ExposeFunction(name string, callback goja.Callable)

func (*BrowserContext) GrantPermissions

func (b *BrowserContext) GrantPermissions(permissions []string, opts goja.Value)

GrantPermissions enables the specified permissions, all others will be disabled.

func (*BrowserContext) NewCDPSession

func (b *BrowserContext) NewCDPSession() api.CDPSession

NewCDPSession returns a new CDP session attached to this target.

func (*BrowserContext) NewPage

func (b *BrowserContext) NewPage() api.Page

NewPage creates a new page inside this browser context.

func (*BrowserContext) Pages

func (b *BrowserContext) Pages() []api.Page

Pages returns a list of pages inside this browser context.

func (*BrowserContext) Route

func (b *BrowserContext) Route(url goja.Value, handler goja.Callable)

func (*BrowserContext) SetDefaultNavigationTimeout

func (b *BrowserContext) SetDefaultNavigationTimeout(timeout int64)

SetDefaultNavigationTimeout sets the default navigation timeout in milliseconds.

func (*BrowserContext) SetDefaultTimeout

func (b *BrowserContext) SetDefaultTimeout(timeout int64)

SetDefaultTimeout sets the default maximum timeout in milliseconds.

func (*BrowserContext) SetExtraHTTPHeaders

func (b *BrowserContext) SetExtraHTTPHeaders(headers map[string]string)

func (*BrowserContext) SetGeolocation

func (b *BrowserContext) SetGeolocation(geolocation goja.Value)

SetGeolocation overrides the geo location of the user.

func (*BrowserContext) SetHTTPCredentials deprecated

func (b *BrowserContext) SetHTTPCredentials(httpCredentials goja.Value)

SetHTTPCredentials sets username/password credentials to use for HTTP authentication.

Deprecated: Create a new BrowserContext with httpCredentials instead. See for details: - https://github.com/microsoft/playwright/issues/2196#issuecomment-627134837 - https://github.com/microsoft/playwright/pull/2763

func (*BrowserContext) SetOffline

func (b *BrowserContext) SetOffline(offline bool)

SetOffline toggles the browser's connectivity on/off.

func (*BrowserContext) StorageState

func (b *BrowserContext) StorageState(opts goja.Value)

func (*BrowserContext) Unroute

func (b *BrowserContext) Unroute(url goja.Value, handler goja.Callable)

func (*BrowserContext) WaitForEvent

func (b *BrowserContext) WaitForEvent(event string, optsOrPredicate goja.Value) interface{}

type BrowserContextOptions

type BrowserContextOptions struct {
	AcceptDownloads   bool              `js:"acceptDownloads"`
	BypassCSP         bool              `js:"bypassCSP"`
	ColorScheme       ColorScheme       `js:"colorScheme"`
	DeviceScaleFactor float64           `js:"deviceScaleFactor"`
	ExtraHTTPHeaders  map[string]string `js:"extraHTTPHeaders"`
	Geolocation       *Geolocation      `js:"geolocation"`
	HasTouch          bool              `js:"hasTouch"`
	HttpCredentials   *Credentials      `js:"httpCredentials"`
	IgnoreHTTPSErrors bool              `js:"ignoreHTTPSErrors"`
	IsMobile          bool              `js:"isMobile"`
	JavaScriptEnabled bool              `js:"javaScriptEnabled"`
	Locale            string            `js:"locale"`
	Offline           bool              `js:"offline"`
	Permissions       []string          `js:"permissions"`
	ReducedMotion     ReducedMotion     `js:"reducedMotion"`
	Screen            *Screen           `js:"screen"`
	TimezoneID        string            `js:"timezoneID"`
	UserAgent         string            `js:"userAgent"`
	VideosPath        string            `js:"videosPath"`
	Viewport          *Viewport         `js:"viewport"`
}

BrowserContextOptions stores browser context options.

func NewBrowserContextOptions

func NewBrowserContextOptions() *BrowserContextOptions

NewBrowserContextOptions creates a default set of browser context options.

func (*BrowserContextOptions) Parse

func (b *BrowserContextOptions) Parse(ctx context.Context, opts goja.Value) error

type BrowserProcess

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

func NewBrowserProcess

func NewBrowserProcess(
	ctx context.Context, cancel context.CancelFunc, process *os.Process, wsURL string, dataDir *storage.Dir,
) *BrowserProcess

func (*BrowserProcess) AttachLogger added in v0.1.2

func (p *BrowserProcess) AttachLogger(logger *log.Logger)

AttachLogger attaches a logger to the browser process.

func (*BrowserProcess) GracefulClose

func (p *BrowserProcess) GracefulClose()

GracefulClose triggers a graceful closing of the browser process.

func (*BrowserProcess) Pid added in v0.1.1

func (p *BrowserProcess) Pid() int

Pid returns the browser process ID.

func (*BrowserProcess) Terminate

func (p *BrowserProcess) Terminate()

Terminate triggers the termination of the browser process.

func (*BrowserProcess) WsURL

func (p *BrowserProcess) WsURL() string

WsURL returns the Websocket URL that the browser is listening on for CDP clients.

type ColorScheme

type ColorScheme string

ColorScheme represents a browser color scheme.

const (
	ColorSchemeLight        ColorScheme = "light"
	ColorSchemeDark         ColorScheme = "dark"
	ColorSchemeNoPreference ColorScheme = "no-preference"
)

Valid color schemes.

func (ColorScheme) MarshalJSON

func (c ColorScheme) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (ColorScheme) String

func (c ColorScheme) String() string

func (*ColorScheme) UnmarshalJSON

func (c *ColorScheme) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

type Connection

type Connection struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}
	Connection represents a WebSocket connection and the root "Browser Session".

	                                      ┌───────────────────────────────────────────────────────────────────┐
                                          │                                                                   │
                                          │                          Browser Process                          │
                                          │                                                                   │
                                          └───────────────────────────────────────────────────────────────────┘

┌───────────────────────────┐ │ ▲ │Reads JSON-RPC CDP messages│ │ │ │from WS connection and puts│ ▼ │ │ them on incoming queue of │ ┌───────────────────────────────────────────────────────────────────┐ │ target session, as ├─────────────■ │ │ identified by message │ │ WebSocket Connection │ │ session ID. Messages │ │ │ │ without a session ID are │ └───────────────────────────────────────────────────────────────────┘ │considered to belong to the│ │ ▲ │ ▲ │ root "Browser Session". │ │ │ │ │ └───────────────────────────┘ ▼ │ ▼ │ ┌───────────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │ Handles CDP messages on ├─────────────■ │ │ │ │incoming queue and puts CDP│ │ Session │ * * * * * │ Session │ │ messages on outgoing │ │ │ │ │ │ channel of WS connection. │ └────────────────────┘ └────────────────────┘ └───────────────────────────┘ │ ▲ │ ▲

│      │                                       │      │
▼      │                                       ▼      │

┌───────────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │Registers with session as a├─────────────■ │ │ │ │handler for a specific CDP │ │ Event Listener │ * * * * * │ Event Listener │ │ Domain event. │ │ │ │ │ └───────────────────────────┘ └────────────────────┘ └────────────────────┘.

func NewConnection

func NewConnection(ctx context.Context, wsURL string, logger *log.Logger) (*Connection, error)

NewConnection creates a new browser.

func (*Connection) Close

func (c *Connection) Close(args ...goja.Value)

func (*Connection) Execute

func (c *Connection) Execute(ctx context.Context, method string, params easyjson.Marshaler, res easyjson.Unmarshaler) error

Execute implements cdproto.Executor and performs a synchronous send and receive.

type Credentials

type Credentials struct {
	Username string `js:"username"`
	Password string `js:"password"`
}

Credentials holds HTTP authentication credentials.

func NewCredentials

func NewCredentials() *Credentials

func (*Credentials) Parse

func (c *Credentials) Parse(ctx context.Context, credentials goja.Value) error

type DOMElementState

type DOMElementState int

DOMElementState represents a DOM element state.

const (
	DOMElementStateAttached DOMElementState = iota
	DOMElementStateDetached
	DOMElementStateVisible
	DOMElementStateHidden
)

Valid DOM element states.

func (DOMElementState) MarshalJSON

func (s DOMElementState) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (DOMElementState) String

func (s DOMElementState) String() string

func (*DOMElementState) UnmarshalJSON

func (s *DOMElementState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

type Device

type Device struct {
	Name              string   `js:"name"`
	UserAgent         string   `js:"userAgent"`
	Viewport          Viewport `js:"viewport"`
	DeviceScaleFactor float64  `js:"deviceScaleFactor"`
	IsMobile          bool     `js:"isMobile"`
	HasTouch          bool     `js:"hasTouch"`
}

Device represents an end-user device (computer, tablet, phone etc.)

type DocumentInfo

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

type ElementHandle

type ElementHandle struct {
	BaseJSHandle
	// contains filtered or unexported fields
}

ElementHandle represents a HTML element JS object inside an execution context.

func (*ElementHandle) AsElement

func (h *ElementHandle) AsElement() api.ElementHandle

AsElement returns this element handle.

func (*ElementHandle) BoundingBox

func (h *ElementHandle) BoundingBox() *api.Rect

BoundingBox returns this element's bounding box.

func (*ElementHandle) Check

func (h *ElementHandle) Check(opts goja.Value)

Check scrolls element into view, and if it's an input element of type checkbox that is unchecked, clicks on it to mark it as checked.

func (*ElementHandle) Click

func (h *ElementHandle) Click(opts goja.Value) *goja.Promise

Click scrolls element into view and clicks in the center of the element TODO: look into making more robust using retries (see: https://github.com/microsoft/playwright/blob/master/src/server/dom.ts#L298)

func (*ElementHandle) ContentFrame

func (h *ElementHandle) ContentFrame() api.Frame

func (*ElementHandle) Dblclick

func (h *ElementHandle) Dblclick(opts goja.Value)

func (*ElementHandle) DispatchEvent

func (h *ElementHandle) DispatchEvent(typ string, eventInit goja.Value)

func (*ElementHandle) Fill

func (h *ElementHandle) Fill(value string, opts goja.Value)

func (*ElementHandle) Focus

func (h *ElementHandle) Focus()

Focus scrolls element into view and focuses the element.

func (*ElementHandle) GetAttribute

func (h *ElementHandle) GetAttribute(name string) goja.Value

GetAttribute retrieves the value of specified element attribute.

func (*ElementHandle) Hover

func (h *ElementHandle) Hover(opts goja.Value)

Hover scrolls element into view and hovers over its center point.

func (*ElementHandle) InnerHTML

func (h *ElementHandle) InnerHTML() string

InnerHTML returns the inner HTML of the element.

func (*ElementHandle) InnerText

func (h *ElementHandle) InnerText() string

InnerText returns the inner text of the element.

func (*ElementHandle) InputValue

func (h *ElementHandle) InputValue(opts goja.Value) string

func (*ElementHandle) IsChecked

func (h *ElementHandle) IsChecked() bool

IsChecked checks if a checkbox or radio is checked.

func (*ElementHandle) IsDisabled

func (h *ElementHandle) IsDisabled() bool

IsDisabled checks if the element is disabled.

func (*ElementHandle) IsEditable

func (h *ElementHandle) IsEditable() bool

IsEditable checks if the element is editable.

func (*ElementHandle) IsEnabled

func (h *ElementHandle) IsEnabled() bool

IsEnabled checks if the element is enabled.

func (*ElementHandle) IsHidden

func (h *ElementHandle) IsHidden() bool

IsHidden checks if the element is hidden.

func (*ElementHandle) IsVisible

func (h *ElementHandle) IsVisible() bool

IsVisible checks if the element is visible.

func (*ElementHandle) OwnerFrame

func (h *ElementHandle) OwnerFrame() api.Frame

OwnerFrame returns the frame containing this element.

func (*ElementHandle) Press

func (h *ElementHandle) Press(key string, opts goja.Value)

func (*ElementHandle) Query

func (h *ElementHandle) Query(selector string) api.ElementHandle

Query runs "element.querySelector" within the page. If no element matches the selector, the return value resolves to "null".

func (*ElementHandle) QueryAll

func (h *ElementHandle) QueryAll(selector string) []api.ElementHandle

QueryAll queries element subtree for matching elements. If no element matches the selector, the return value resolves to "null".

func (*ElementHandle) Screenshot

func (h *ElementHandle) Screenshot(opts goja.Value) goja.ArrayBuffer

func (*ElementHandle) ScrollIntoViewIfNeeded

func (h *ElementHandle) ScrollIntoViewIfNeeded(opts goja.Value)

func (*ElementHandle) SelectOption

func (h *ElementHandle) SelectOption(values goja.Value, opts goja.Value) []string

func (*ElementHandle) SelectText

func (h *ElementHandle) SelectText(opts goja.Value)

func (*ElementHandle) SetChecked

func (h *ElementHandle) SetChecked(checked bool, opts goja.Value)

SetChecked checks or unchecks an element.

func (*ElementHandle) SetInputFiles

func (h *ElementHandle) SetInputFiles(files goja.Value, opts goja.Value)

func (*ElementHandle) Tap

func (h *ElementHandle) Tap(opts goja.Value)

func (*ElementHandle) TextContent

func (h *ElementHandle) TextContent() string

func (*ElementHandle) Type

func (h *ElementHandle) Type(text string, opts goja.Value)

Type scrolls element into view, focuses element and types text.

func (*ElementHandle) Uncheck

func (h *ElementHandle) Uncheck(opts goja.Value)

Uncheck scrolls element into view, and if it's an input element of type checkbox that is already checked, clicks on it to mark it as unchecked.

func (*ElementHandle) WaitForElementState

func (h *ElementHandle) WaitForElementState(state string, opts goja.Value)

func (*ElementHandle) WaitForSelector

func (h *ElementHandle) WaitForSelector(selector string, opts goja.Value) api.ElementHandle

type ElementHandleBaseOptions

type ElementHandleBaseOptions struct {
	Force       bool          `json:"force"`
	NoWaitAfter bool          `json:"noWaitAfter"`
	Timeout     time.Duration `json:"timeout"`
}

func NewElementHandleBaseOptions

func NewElementHandleBaseOptions(defaultTimeout time.Duration) *ElementHandleBaseOptions

func (*ElementHandleBaseOptions) Parse

type ElementHandleBasePointerOptions

type ElementHandleBasePointerOptions struct {
	ElementHandleBaseOptions
	Position *Position `json:"position"`
	Trial    bool      `json:"trial"`
}

func NewElementHandleBasePointerOptions

func NewElementHandleBasePointerOptions(defaultTimeout time.Duration) *ElementHandleBasePointerOptions

func (*ElementHandleBasePointerOptions) Parse

type ElementHandleCheckOptions

type ElementHandleCheckOptions struct {
	ElementHandleBasePointerOptions
}

func NewElementHandleCheckOptions

func NewElementHandleCheckOptions(defaultTimeout time.Duration) *ElementHandleCheckOptions

func (*ElementHandleCheckOptions) Parse

type ElementHandleClickOptions

type ElementHandleClickOptions struct {
	ElementHandleBasePointerOptions
	Button     string   `json:"button"`
	ClickCount int64    `json:"clickCount"`
	Delay      int64    `json:"delay"`
	Modifiers  []string `json:"modifiers"`
}

func NewElementHandleClickOptions

func NewElementHandleClickOptions(defaultTimeout time.Duration) *ElementHandleClickOptions

func (*ElementHandleClickOptions) Parse

func (*ElementHandleClickOptions) ToMouseClickOptions

func (o *ElementHandleClickOptions) ToMouseClickOptions() *MouseClickOptions

type ElementHandleDblclickOptions

type ElementHandleDblclickOptions struct {
	ElementHandleBasePointerOptions
	Button    string   `json:"button"`
	Delay     int64    `json:"delay"`
	Modifiers []string `json:"modifiers"`
}

func NewElementHandleDblclickOptions

func NewElementHandleDblclickOptions(defaultTimeout time.Duration) *ElementHandleDblclickOptions

func (*ElementHandleDblclickOptions) Parse

func (*ElementHandleDblclickOptions) ToMouseClickOptions

func (o *ElementHandleDblclickOptions) ToMouseClickOptions() *MouseClickOptions

type ElementHandleDispatchEventOptions added in v0.4.0

type ElementHandleDispatchEventOptions struct {
	*ElementHandleBaseOptions
}

ElementHandleDispatchEventOptions are options for ElementHandle.dispatchEvent.

func NewElementHandleDispatchEventOptions added in v0.4.0

func NewElementHandleDispatchEventOptions(defaultTimeout time.Duration) *ElementHandleDispatchEventOptions

NewElementHandleDispatchEventOptions returns a new ElementHandleDispatchEventOptions.

type ElementHandleHoverOptions

type ElementHandleHoverOptions struct {
	ElementHandleBasePointerOptions
	Modifiers []string `json:"modifiers"`
}

func NewElementHandleHoverOptions

func NewElementHandleHoverOptions(defaultTimeout time.Duration) *ElementHandleHoverOptions

func (*ElementHandleHoverOptions) Parse

type ElementHandlePressOptions

type ElementHandlePressOptions struct {
	Delay       int64         `json:"delay"`
	NoWaitAfter bool          `json:"noWaitAfter"`
	Timeout     time.Duration `json:"timeout"`
}

func NewElementHandlePressOptions

func NewElementHandlePressOptions(defaultTimeout time.Duration) *ElementHandlePressOptions

func (*ElementHandlePressOptions) Parse

func (*ElementHandlePressOptions) ToBaseOptions

type ElementHandleScreenshotOptions

type ElementHandleScreenshotOptions struct {
	Path           string        `json:"path"`
	Format         ImageFormat   `json:"format"`
	OmitBackground bool          `json:"omitBackground"`
	Quality        int64         `json:"quality"`
	Timeout        time.Duration `json:"timeout"`
}

func NewElementHandleScreenshotOptions

func NewElementHandleScreenshotOptions(defaultTimeout time.Duration) *ElementHandleScreenshotOptions

func (*ElementHandleScreenshotOptions) Parse

type ElementHandleSetCheckedOptions

type ElementHandleSetCheckedOptions struct {
	ElementHandleBasePointerOptions
	Strict bool `json:"strict"`
}

func NewElementHandleSetCheckedOptions

func NewElementHandleSetCheckedOptions(defaultTimeout time.Duration) *ElementHandleSetCheckedOptions

func (*ElementHandleSetCheckedOptions) Parse

type ElementHandleTapOptions

type ElementHandleTapOptions struct {
	ElementHandleBasePointerOptions
	Modifiers []string `json:"modifiers"`
}

func NewElementHandleTapOptions

func NewElementHandleTapOptions(defaultTimeout time.Duration) *ElementHandleTapOptions

func (*ElementHandleTapOptions) Parse

func (o *ElementHandleTapOptions) Parse(ctx context.Context, opts goja.Value) error

type ElementHandleTypeOptions

type ElementHandleTypeOptions struct {
	Delay       int64         `json:"delay"`
	NoWaitAfter bool          `json:"noWaitAfter"`
	Timeout     time.Duration `json:"timeout"`
}

func NewElementHandleTypeOptions

func NewElementHandleTypeOptions(defaultTimeout time.Duration) *ElementHandleTypeOptions

func (*ElementHandleTypeOptions) Parse

func (*ElementHandleTypeOptions) ToBaseOptions

type ElementHandleWaitForElementStateOptions

type ElementHandleWaitForElementStateOptions struct {
	Timeout time.Duration `json:"timeout"`
}

func NewElementHandleWaitForElementStateOptions

func NewElementHandleWaitForElementStateOptions(defaultTimeout time.Duration) *ElementHandleWaitForElementStateOptions

func (*ElementHandleWaitForElementStateOptions) Parse

type EmulatedSize

type EmulatedSize struct {
	Viewport *Viewport
	Screen   *Screen
}

func NewEmulatedSize

func NewEmulatedSize(viewport *Viewport, screen *Screen) *EmulatedSize

type Error

type Error string

Error is a common package error.

const (
	ErrUnexpectedRemoteObjectWithID Error = "cannot extract value when remote object ID is given"
	ErrChannelClosed                Error = "channel closed"
	ErrFrameDetached                Error = "frame detached"
	ErrJSHandleDisposed             Error = "JS handle is disposed"
	ErrJSHandleInvalid              Error = "JS handle is invalid"
	ErrTargetCrashed                Error = "Target has crashed"
	ErrTimedOut                     Error = "timed out"
	ErrWrongExecutionContext        Error = "JS handles can be evaluated only in the context they were created"
)

Error types.

func (Error) Error

func (e Error) Error() string

Error satisfies the builtin error interface.

type Event

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

Event as emitted by an EventEmiter.

type EventEmitter

type EventEmitter interface {
	// contains filtered or unexported methods
}

EventEmitter that all event emitters need to implement.

type ExecutionContext

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

ExecutionContext represents a JS execution context.

func NewExecutionContext

func NewExecutionContext(
	ctx context.Context, s session, f *Frame, id runtime.ExecutionContextID, l *log.Logger,
) *ExecutionContext

NewExecutionContext creates a new JS execution context.

func (*ExecutionContext) Eval added in v0.2.0

func (e *ExecutionContext) Eval(
	apiCtx context.Context, js goja.Value, args ...goja.Value,
) (interface{}, error)

Eval evaluates the provided JavaScript within this execution context and returns a value or handle.

func (*ExecutionContext) EvalHandle added in v0.2.0

func (e *ExecutionContext) EvalHandle(
	apiCtx context.Context, js goja.Value, args ...goja.Value,
) (api.JSHandle, error)

EvalHandle evaluates the provided JavaScript within this execution context and returns a JSHandle.

func (*ExecutionContext) Frame

func (e *ExecutionContext) Frame() *Frame

Frame returns the frame that this execution context belongs to.

func (*ExecutionContext) ID added in v0.1.2

ID returns the CDP runtime ID of this execution context.

type FieldNameMapper

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

FieldNameMapper for goja.Runtime.SetFieldNameMapper().

func NewFieldNameMapper

func NewFieldNameMapper() *FieldNameMapper

NewFieldNameMapper creates a new field name mapper to add some method name exceptions needed for the xk6-browser extension.

func (*FieldNameMapper) FieldName

func (fm *FieldNameMapper) FieldName(t reflect.Type, f reflect.StructField) string

FieldName is part of the goja.FieldNameMapper interface https://godoc.org/github.com/dop251/goja#FieldNameMapper

func (*FieldNameMapper) MethodName

func (fm *FieldNameMapper) MethodName(t reflect.Type, m reflect.Method) string

MethodName is part of the goja.FieldNameMapper interface https://godoc.org/github.com/dop251/goja#FieldNameMapper

type Frame

type Frame struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

Frame represents a frame in an HTML document.

func NewFrame

func NewFrame(
	ctx context.Context, m *FrameManager, parentFrame *Frame, frameID cdp.FrameID, log *log.Logger,
) *Frame

NewFrame creates a new HTML document frame.

func (*Frame) AddScriptTag

func (f *Frame) AddScriptTag(opts goja.Value)

func (*Frame) AddStyleTag

func (f *Frame) AddStyleTag(opts goja.Value)

func (*Frame) Check

func (f *Frame) Check(selector string, opts goja.Value)

Check clicks the first element found that matches selector.

func (*Frame) ChildFrames

func (f *Frame) ChildFrames() []api.Frame

ChildFrames returns a list of child frames.

func (*Frame) Click

func (f *Frame) Click(selector string, opts goja.Value) *goja.Promise

Click clicks the first element found that matches selector.

func (*Frame) Content

func (f *Frame) Content() string

Content returns the HTML content of the frame.

func (*Frame) Dblclick

func (f *Frame) Dblclick(selector string, opts goja.Value)

Dblclick double clicks an element matching provided selector.

func (*Frame) DispatchEvent

func (f *Frame) DispatchEvent(selector, typ string, eventInit, opts goja.Value)

DispatchEvent dispatches an event for the first element matching the selector.

func (*Frame) Evaluate

func (f *Frame) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}

Evaluate will evaluate provided page function within an execution context.

func (*Frame) EvaluateHandle

func (f *Frame) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) (handle api.JSHandle)

EvaluateHandle will evaluate provided page function within an execution context.

func (*Frame) Fill

func (f *Frame) Fill(selector, value string, opts goja.Value)

Fill fills out the first element found that matches the selector.

func (*Frame) Focus

func (f *Frame) Focus(selector string, opts goja.Value)

Focus focuses on the first element that matches the selector.

func (*Frame) FrameElement

func (f *Frame) FrameElement() api.ElementHandle

func (*Frame) GetAttribute

func (f *Frame) GetAttribute(selector, name string, opts goja.Value) goja.Value

GetAttribute of the first element found that matches the selector.

func (*Frame) Goto

func (f *Frame) Goto(url string, opts goja.Value) api.Response

Goto will navigate the frame to the specified URL and return a HTTP response object.

func (*Frame) Hover

func (f *Frame) Hover(selector string, opts goja.Value)

Hover moves the pointer over the first element that matches the selector.

func (*Frame) ID

func (f *Frame) ID() string

ID returns the frame id.

func (*Frame) InnerHTML

func (f *Frame) InnerHTML(selector string, opts goja.Value) string

InnerHTML returns the innerHTML attribute of the first element found that matches the selector.

func (*Frame) InnerText

func (f *Frame) InnerText(selector string, opts goja.Value) string

InnerText returns the inner text of the first element found that matches the selector.

func (*Frame) InputValue

func (f *Frame) InputValue(selector string, opts goja.Value) string

InputValue returns the input value of the first element found that matches the selector.

func (*Frame) IsChecked

func (f *Frame) IsChecked(selector string, opts goja.Value) bool

IsChecked returns true if the first element that matches the selector is checked. Otherwise, returns false.

func (*Frame) IsDetached

func (f *Frame) IsDetached() bool

IsDetached returns whether the frame is detached or not.

func (*Frame) IsDisabled

func (f *Frame) IsDisabled(selector string, opts goja.Value) bool

IsDisabled returns true if the first element that matches the selector is disabled. Otherwise, returns false.

func (*Frame) IsEditable

func (f *Frame) IsEditable(selector string, opts goja.Value) bool

IsEditable returns true if the first element that matches the selector is editable. Otherwise, returns false.

func (*Frame) IsEnabled

func (f *Frame) IsEnabled(selector string, opts goja.Value) bool

IsEnabled returns true if the first element that matches the selector is enabled. Otherwise, returns false.

func (*Frame) IsHidden

func (f *Frame) IsHidden(selector string, opts goja.Value) bool

IsHidden returns true if the first element that matches the selector is hidden. Otherwise, returns false.

func (*Frame) IsVisible

func (f *Frame) IsVisible(selector string, opts goja.Value) bool

IsVisible returns true if the first element that matches the selector is visible. Otherwise, returns false.

func (*Frame) LoaderID

func (f *Frame) LoaderID() string

LoaderID returns the ID of the frame that loaded this frame.

func (*Frame) Locator added in v0.4.0

func (f *Frame) Locator(selector string, opts goja.Value) api.Locator

Locator creates and returns a new locator for this frame.

func (*Frame) Name

func (f *Frame) Name() string

Name returns the frame name.

func (*Frame) Page

func (f *Frame) Page() api.Page

Page returns page that owns frame.

func (*Frame) ParentFrame

func (f *Frame) ParentFrame() api.Frame

ParentFrame returns the parent frame, if one exists.

func (*Frame) Press

func (f *Frame) Press(selector, key string, opts goja.Value)

Press presses the given key for the first element found that matches the selector.

func (*Frame) Query

func (f *Frame) Query(selector string) api.ElementHandle

Query runs a selector query against the document tree, returning the first matching element or "null" if no match is found.

func (*Frame) QueryAll

func (f *Frame) QueryAll(selector string) []api.ElementHandle

func (*Frame) SelectOption

func (f *Frame) SelectOption(selector string, values goja.Value, opts goja.Value) []string

SelectOption selects the given options and returns the array of option values of the first element found that matches the selector.

func (*Frame) SetContent

func (f *Frame) SetContent(html string, opts goja.Value)

SetContent replaces the entire HTML document content.

func (*Frame) SetInputFiles

func (f *Frame) SetInputFiles(selector string, files goja.Value, opts goja.Value)

func (*Frame) Tap

func (f *Frame) Tap(selector string, opts goja.Value)

Tap the first element that matches the selector.

func (*Frame) TextContent

func (f *Frame) TextContent(selector string, opts goja.Value) string

TextContent returns the textContent attribute of the first element found that matches the selector.

func (*Frame) Title

func (f *Frame) Title() string

func (*Frame) Type

func (f *Frame) Type(selector, text string, opts goja.Value)

Type text on the first element found matches the selector.

func (*Frame) URL

func (f *Frame) URL() string

URL returns the frame URL.

func (*Frame) Uncheck

func (f *Frame) Uncheck(selector string, opts goja.Value)

Uncheck the first found element that matches the selector.

func (*Frame) WaitForFunction

func (f *Frame) WaitForFunction(fn goja.Value, opts goja.Value, jsArgs ...goja.Value) *goja.Promise

WaitForFunction waits for the given predicate to return a truthy value.

func (*Frame) WaitForLoadState

func (f *Frame) WaitForLoadState(state string, opts goja.Value)

WaitForLoadState waits for the given load state to be reached.

func (*Frame) WaitForNavigation

func (f *Frame) WaitForNavigation(opts goja.Value) *goja.Promise

WaitForNavigation waits for the given navigation lifecycle event to happen.

func (*Frame) WaitForSelector

func (f *Frame) WaitForSelector(selector string, opts goja.Value) api.ElementHandle

WaitForSelector waits for the given selector to match the waiting criteria.

func (*Frame) WaitForTimeout

func (f *Frame) WaitForTimeout(timeout int64)

WaitForTimeout waits the specified amount of milliseconds.

type FrameBaseOptions

type FrameBaseOptions struct {
	Timeout time.Duration `json:"timeout"`
	Strict  bool          `json:"strict"`
}

func NewFrameBaseOptions

func NewFrameBaseOptions(defaultTimeout time.Duration) *FrameBaseOptions

func (*FrameBaseOptions) Parse

func (o *FrameBaseOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameCheckOptions

type FrameCheckOptions struct {
	ElementHandleBasePointerOptions
	Strict bool `json:"strict"`
}

func NewFrameCheckOptions

func NewFrameCheckOptions(defaultTimeout time.Duration) *FrameCheckOptions

func (*FrameCheckOptions) Parse

func (o *FrameCheckOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameClickOptions

type FrameClickOptions struct {
	ElementHandleClickOptions
	Strict bool `json:"strict"`
}

func NewFrameClickOptions

func NewFrameClickOptions(defaultTimeout time.Duration) *FrameClickOptions

func (*FrameClickOptions) Parse

func (o *FrameClickOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameDblclickOptions

type FrameDblclickOptions struct {
	ElementHandleDblclickOptions
	Strict bool `json:"strict"`
}

func NewFrameDblClickOptions

func NewFrameDblClickOptions(defaultTimeout time.Duration) *FrameDblclickOptions

func (*FrameDblclickOptions) Parse

func (o *FrameDblclickOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameDispatchEventOptions added in v0.4.0

type FrameDispatchEventOptions struct {
	*FrameBaseOptions
}

FrameDispatchEventOptions are options for Frame.dispatchEvent.

func NewFrameDispatchEventOptions added in v0.4.0

func NewFrameDispatchEventOptions(defaultTimeout time.Duration) *FrameDispatchEventOptions

NewFrameDispatchEventOptions returns a new FrameDispatchEventOptions.

type FrameFillOptions

type FrameFillOptions struct {
	ElementHandleBaseOptions
	Strict bool `json:"strict"`
}

func NewFrameFillOptions

func NewFrameFillOptions(defaultTimeout time.Duration) *FrameFillOptions

func (*FrameFillOptions) Parse

func (o *FrameFillOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameGotoOptions

type FrameGotoOptions struct {
	Referer   string         `json:"referer"`
	Timeout   time.Duration  `json:"timeout"`
	WaitUntil LifecycleEvent `json:"waitUntil"`
}

func NewFrameGotoOptions

func NewFrameGotoOptions(defaultReferer string, defaultTimeout time.Duration) *FrameGotoOptions

func (*FrameGotoOptions) Parse

func (o *FrameGotoOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameHoverOptions

type FrameHoverOptions struct {
	ElementHandleHoverOptions
	Strict bool `json:"strict"`
}

func NewFrameHoverOptions

func NewFrameHoverOptions(defaultTimeout time.Duration) *FrameHoverOptions

func (*FrameHoverOptions) Parse

func (o *FrameHoverOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameInnerHTMLOptions

type FrameInnerHTMLOptions struct {
	FrameBaseOptions
}

func NewFrameInnerHTMLOptions

func NewFrameInnerHTMLOptions(defaultTimeout time.Duration) *FrameInnerHTMLOptions

func (*FrameInnerHTMLOptions) Parse

func (o *FrameInnerHTMLOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameInnerTextOptions

type FrameInnerTextOptions struct {
	FrameBaseOptions
}

func NewFrameInnerTextOptions

func NewFrameInnerTextOptions(defaultTimeout time.Duration) *FrameInnerTextOptions

func (*FrameInnerTextOptions) Parse

func (o *FrameInnerTextOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameInputValueOptions

type FrameInputValueOptions struct {
	FrameBaseOptions
}

func NewFrameInputValueOptions

func NewFrameInputValueOptions(defaultTimeout time.Duration) *FrameInputValueOptions

func (*FrameInputValueOptions) Parse

func (o *FrameInputValueOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsCheckedOptions

type FrameIsCheckedOptions struct {
	FrameBaseOptions
}

func NewFrameIsCheckedOptions

func NewFrameIsCheckedOptions(defaultTimeout time.Duration) *FrameIsCheckedOptions

func (*FrameIsCheckedOptions) Parse

func (o *FrameIsCheckedOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsDisabledOptions

type FrameIsDisabledOptions struct {
	FrameBaseOptions
}

func NewFrameIsDisabledOptions

func NewFrameIsDisabledOptions(defaultTimeout time.Duration) *FrameIsDisabledOptions

func (*FrameIsDisabledOptions) Parse

func (o *FrameIsDisabledOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsEditableOptions

type FrameIsEditableOptions struct {
	FrameBaseOptions
}

func NewFrameIsEditableOptions

func NewFrameIsEditableOptions(defaultTimeout time.Duration) *FrameIsEditableOptions

func (*FrameIsEditableOptions) Parse

func (o *FrameIsEditableOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsEnabledOptions

type FrameIsEnabledOptions struct {
	FrameBaseOptions
}

func NewFrameIsEnabledOptions

func NewFrameIsEnabledOptions(defaultTimeout time.Duration) *FrameIsEnabledOptions

func (*FrameIsEnabledOptions) Parse

func (o *FrameIsEnabledOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsHiddenOptions

type FrameIsHiddenOptions struct {
	FrameBaseOptions
}

func NewFrameIsHiddenOptions

func NewFrameIsHiddenOptions(defaultTimeout time.Duration) *FrameIsHiddenOptions

func (*FrameIsHiddenOptions) Parse

func (o *FrameIsHiddenOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameIsVisibleOptions

type FrameIsVisibleOptions struct {
	FrameBaseOptions
}

func NewFrameIsVisibleOptions

func NewFrameIsVisibleOptions(defaultTimeout time.Duration) *FrameIsVisibleOptions

func (*FrameIsVisibleOptions) Parse

func (o *FrameIsVisibleOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameManager

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

FrameManager manages all frames in a page and their life-cycles, it's a purely internal component.

func NewFrameManager

func NewFrameManager(
	ctx context.Context,
	s session,
	p *Page,
	ts *TimeoutSettings,
	l *log.Logger,
) *FrameManager

NewFrameManager creates a new HTML document frame manager.

func (*FrameManager) Frames

func (m *FrameManager) Frames() []api.Frame

Frames returns a list of frames on the page.

func (*FrameManager) ID added in v0.1.3

func (m *FrameManager) ID() int64

ID returns the unique ID of a FrameManager value.

func (*FrameManager) MainFrame

func (m *FrameManager) MainFrame() *Frame

MainFrame returns the main frame of the page.

func (*FrameManager) NavigateFrame

func (m *FrameManager) NavigateFrame(frame *Frame, url string, opts goja.Value) api.Response

NavigateFrame will navigate specified frame to specified URL.

func (*FrameManager) Page

func (m *FrameManager) Page() api.Page

Page returns the page that this frame manager belongs to.

type FramePressOptions

type FramePressOptions struct {
	ElementHandlePressOptions
	Strict bool `json:"strict"`
}

func NewFramePressOptions

func NewFramePressOptions(defaultTimeout time.Duration) *FramePressOptions

func (*FramePressOptions) ToKeyboardOptions

func (o *FramePressOptions) ToKeyboardOptions() *KeyboardOptions

type FrameSelectOptionOptions

type FrameSelectOptionOptions struct {
	ElementHandleBaseOptions
	Strict bool `json:"strict"`
}

func NewFrameSelectOptionOptions

func NewFrameSelectOptionOptions(defaultTimeout time.Duration) *FrameSelectOptionOptions

func (*FrameSelectOptionOptions) Parse

type FrameSession

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

FrameSession is used for managing a frame's life-cycle, or in other words its full session. It manages all the event listening while deferring the state storage to the Frame and FrameManager structs.

func NewFrameSession

func NewFrameSession(
	ctx context.Context, s session, p *Page, parent *FrameSession, tid target.ID, l *log.Logger,
) (_ *FrameSession, err error)

NewFrameSession initializes and returns a new FrameSession.

type FrameSetContentOptions

type FrameSetContentOptions struct {
	Timeout   time.Duration  `json:"timeout"`
	WaitUntil LifecycleEvent `json:"waitUntil"`
}

func NewFrameSetContentOptions

func NewFrameSetContentOptions(defaultTimeout time.Duration) *FrameSetContentOptions

func (*FrameSetContentOptions) Parse

func (o *FrameSetContentOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameTapOptions

type FrameTapOptions struct {
	ElementHandleBasePointerOptions
	Modifiers []string `json:"modifiers"`
	Strict    bool     `json:"strict"`
}

func NewFrameTapOptions

func NewFrameTapOptions(defaultTimeout time.Duration) *FrameTapOptions

func (*FrameTapOptions) Parse

func (o *FrameTapOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameTextContentOptions

type FrameTextContentOptions struct {
	FrameBaseOptions
}

func NewFrameTextContentOptions

func NewFrameTextContentOptions(defaultTimeout time.Duration) *FrameTextContentOptions

func (*FrameTextContentOptions) Parse

func (o *FrameTextContentOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameTypeOptions

type FrameTypeOptions struct {
	ElementHandleTypeOptions
	Strict bool `json:"strict"`
}

func NewFrameTypeOptions

func NewFrameTypeOptions(defaultTimeout time.Duration) *FrameTypeOptions

func (*FrameTypeOptions) ToKeyboardOptions

func (o *FrameTypeOptions) ToKeyboardOptions() *KeyboardOptions

type FrameUncheckOptions

type FrameUncheckOptions struct {
	ElementHandleBasePointerOptions
	Strict bool `json:"strict"`
}

func NewFrameUncheckOptions

func NewFrameUncheckOptions(defaultTimeout time.Duration) *FrameUncheckOptions

func (*FrameUncheckOptions) Parse

func (o *FrameUncheckOptions) Parse(ctx context.Context, opts goja.Value) error

type FrameWaitForFunctionOptions

type FrameWaitForFunctionOptions struct {
	Polling  PollingType   `json:"polling"`
	Interval int64         `json:"interval"`
	Timeout  time.Duration `json:"timeout"`
}

func NewFrameWaitForFunctionOptions

func NewFrameWaitForFunctionOptions(defaultTimeout time.Duration) *FrameWaitForFunctionOptions

func (*FrameWaitForFunctionOptions) Parse

Parse JavaScript waitForFunction options.

type FrameWaitForLoadStateOptions

type FrameWaitForLoadStateOptions struct {
	Timeout time.Duration `json:"timeout"`
}

func NewFrameWaitForLoadStateOptions

func NewFrameWaitForLoadStateOptions(defaultTimeout time.Duration) *FrameWaitForLoadStateOptions

func (*FrameWaitForLoadStateOptions) Parse

type FrameWaitForNavigationOptions

type FrameWaitForNavigationOptions struct {
	URL       string         `json:"url"`
	WaitUntil LifecycleEvent `json:"waitUntil"`
	Timeout   time.Duration  `json:"timeout"`
}

func NewFrameWaitForNavigationOptions

func NewFrameWaitForNavigationOptions(defaultTimeout time.Duration) *FrameWaitForNavigationOptions

func (*FrameWaitForNavigationOptions) Parse

type FrameWaitForSelectorOptions

type FrameWaitForSelectorOptions struct {
	State   DOMElementState `json:"state"`
	Strict  bool            `json:"strict"`
	Timeout time.Duration   `json:"timeout"`
}

func NewFrameWaitForSelectorOptions

func NewFrameWaitForSelectorOptions(defaultTimeout time.Duration) *FrameWaitForSelectorOptions

func (*FrameWaitForSelectorOptions) Parse

type Geolocation

type Geolocation struct {
	Latitude  float64 `js:"latitude"`
	Longitude float64 `js:"longitude"`
	Accurracy float64 `js:"accurracy"`
}

func NewGeolocation

func NewGeolocation() *Geolocation

func (*Geolocation) Parse

func (g *Geolocation) Parse(ctx context.Context, opts goja.Value) error

type Hook

type Hook func(context.Context)

type HookID

type HookID int
const (
	HookApplySlowMo HookID = iota
)

type Hooks

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

func GetHooks

func GetHooks(ctx context.Context) *Hooks

func NewHooks

func NewHooks() *Hooks

func (*Hooks) Get

func (h *Hooks) Get(id HookID) Hook

func (*Hooks) Register

func (h *Hooks) Register(id HookID, hook Hook)

type ImageFormat

type ImageFormat string

ImageFormat represents an image file format.

const (
	ImageFormatJPEG ImageFormat = "jpeg"
	ImageFormatPNG  ImageFormat = "png"
)

Valid image format options.

func (ImageFormat) MarshalJSON

func (f ImageFormat) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (ImageFormat) String

func (f ImageFormat) String() string

func (*ImageFormat) UnmarshalJSON

func (f *ImageFormat) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

type Keyboard

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

Keyboard represents a keyboard input device. Each Page has a publicly accessible Keyboard.

func NewKeyboard

func NewKeyboard(ctx context.Context, s session) *Keyboard

NewKeyboard returns a new keyboard with a "us" layout.

func (*Keyboard) Down

func (k *Keyboard) Down(key string)

Down sends a key down message to a session target.

func (*Keyboard) InsertText

func (k *Keyboard) InsertText(text string)

InsertText inserts a text without dispatching key events.

func (*Keyboard) Press

func (k *Keyboard) Press(key string, opts goja.Value)

Press sends a key press message to a session target. It delays the action if `Delay` option is specified. A press message consists of successive key down and up messages.

func (*Keyboard) Type

func (k *Keyboard) Type(text string, opts goja.Value)

Type sends a press message to a session target for each character in text. It delays the action if `Delay` option is specified.

It sends an insertText message if a character is not among valid characters in the keyboard's layout.

func (*Keyboard) Up

func (k *Keyboard) Up(key string)

Up sends a key up message to a session target.

type KeyboardOptions

type KeyboardOptions struct {
	Delay int64 `json:"delay"`
}

func NewKeyboardOptions

func NewKeyboardOptions() *KeyboardOptions

func (*KeyboardOptions) Parse

func (o *KeyboardOptions) Parse(ctx context.Context, opts goja.Value) error

type LaunchOptions

type LaunchOptions struct {
	Args              []string
	Debug             bool
	Devtools          bool
	Env               map[string]string
	ExecutablePath    string
	Headless          bool
	IgnoreDefaultArgs []string
	LogCategoryFilter string
	Proxy             ProxyOptions
	SlowMo            time.Duration
	Timeout           time.Duration
}

LaunchOptions stores browser launch options.

func GetLaunchOptions

func GetLaunchOptions(ctx context.Context) *LaunchOptions

func NewLaunchOptions

func NewLaunchOptions() *LaunchOptions

func (*LaunchOptions) Parse

func (l *LaunchOptions) Parse(ctx context.Context, opts goja.Value) error

Parse parses launch options from a JS object.

type LaunchPersistentContextOptions

type LaunchPersistentContextOptions struct {
	LaunchOptions
	BrowserContextOptions
}

LaunchPersistentContextOptions stores browser launch options for persistent context.

type LifecycleEvent

type LifecycleEvent int
const (
	LifecycleEventLoad LifecycleEvent = iota
	LifecycleEventDOMContentLoad
	LifecycleEventNetworkIdle
)

func (LifecycleEvent) MarshalJSON

func (l LifecycleEvent) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (*LifecycleEvent) MarshalText added in v0.3.0

func (l *LifecycleEvent) MarshalText() ([]byte, error)

MarshalText returns the string representation of the enum value. It returns an error if the enum value is invalid.

func (LifecycleEvent) String

func (l LifecycleEvent) String() string

func (*LifecycleEvent) UnmarshalJSON

func (l *LifecycleEvent) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

func (*LifecycleEvent) UnmarshalText added in v0.3.0

func (l *LifecycleEvent) UnmarshalText(text []byte) error

UnmarshalText unmarshals a text representation to the enum value. It returns an error if given a wrong value.

type Locator added in v0.4.0

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

Locator represent a way to find element(s) on the page at any moment.

func NewLocator added in v0.4.0

func NewLocator(ctx context.Context, selector string, f *Frame, l *log.Logger) *Locator

NewLocator creates and returns a new locator.

func (*Locator) Check added in v0.4.0

func (l *Locator) Check(opts goja.Value)

Check on an element using locator's selector with strict mode on.

func (*Locator) Click added in v0.4.0

func (l *Locator) Click(opts goja.Value)

Click on an element using locator's selector with strict mode on.

func (*Locator) Dblclick added in v0.4.0

func (l *Locator) Dblclick(opts goja.Value)

Dblclick double clicks on an element using locator's selector with strict mode on.

func (*Locator) DispatchEvent added in v0.4.0

func (l *Locator) DispatchEvent(typ string, eventInit, opts goja.Value)

DispatchEvent dispatches an event for the element matching the locator's selector with strict mode on.

func (*Locator) Fill added in v0.4.0

func (l *Locator) Fill(value string, opts goja.Value)

Fill out the element using locator's selector with strict mode on.

func (*Locator) Focus added in v0.4.0

func (l *Locator) Focus(opts goja.Value)

Focus on the element using locator's selector with strict mode on.

func (*Locator) GetAttribute added in v0.4.0

func (l *Locator) GetAttribute(name string, opts goja.Value) goja.Value

GetAttribute of the element using locator's selector with strict mode on.

func (*Locator) Hover added in v0.4.0

func (l *Locator) Hover(opts goja.Value)

Hover moves the pointer over the element that matches the locator's selector with strict mode on.

func (*Locator) InnerHTML added in v0.4.0

func (l *Locator) InnerHTML(opts goja.Value) string

InnerHTML returns the element's inner HTML that matches the locator's selector with strict mode on.

func (*Locator) InnerText added in v0.4.0

func (l *Locator) InnerText(opts goja.Value) string

InnerText returns the element's inner text that matches the locator's selector with strict mode on.

func (*Locator) InputValue added in v0.4.0

func (l *Locator) InputValue(opts goja.Value) string

InputValue returns the element's input value that matches the locator's selector with strict mode on.

func (*Locator) IsChecked added in v0.4.0

func (l *Locator) IsChecked(opts goja.Value) bool

IsChecked returns true if the element matches the locator's selector and is checked. Otherwise, returns false.

func (*Locator) IsDisabled added in v0.4.0

func (l *Locator) IsDisabled(opts goja.Value) bool

IsDisabled returns true if the element matches the locator's selector and is disabled. Otherwise, returns false.

func (*Locator) IsEditable added in v0.4.0

func (l *Locator) IsEditable(opts goja.Value) bool

IsEditable returns true if the element matches the locator's selector and is Editable. Otherwise, returns false.

func (*Locator) IsEnabled added in v0.4.0

func (l *Locator) IsEnabled(opts goja.Value) bool

IsEnabled returns true if the element matches the locator's selector and is Enabled. Otherwise, returns false.

func (*Locator) IsHidden added in v0.4.0

func (l *Locator) IsHidden(opts goja.Value) bool

IsHidden returns true if the element matches the locator's selector and is hidden. Otherwise, returns false.

func (*Locator) IsVisible added in v0.4.0

func (l *Locator) IsVisible(opts goja.Value) bool

IsVisible returns true if the element matches the locator's selector and is visible. Otherwise, returns false.

func (*Locator) Press added in v0.4.0

func (l *Locator) Press(key string, opts goja.Value)

Press the given key on the element found that matches the locator's selector with strict mode on.

func (*Locator) SelectOption added in v0.4.0

func (l *Locator) SelectOption(values goja.Value, opts goja.Value) []string

SelectOption filters option values of the first element that matches the locator's selector (with strict mode on), selects the options, and returns the filtered options.

func (*Locator) Tap added in v0.4.0

func (l *Locator) Tap(opts goja.Value)

Tap the element found that matches the locator's selector with strict mode on.

func (*Locator) TextContent added in v0.4.0

func (l *Locator) TextContent(opts goja.Value) string

TextContent returns the element's text content that matches the locator's selector with strict mode on.

func (*Locator) Type added in v0.4.0

func (l *Locator) Type(text string, opts goja.Value)

Type text on the element found that matches the locator's selector with strict mode on.

func (*Locator) Uncheck added in v0.4.0

func (l *Locator) Uncheck(opts goja.Value)

Uncheck on an element using locator's selector with strict mode on.

func (*Locator) WaitFor added in v0.4.0

func (l *Locator) WaitFor(opts goja.Value)

WaitFor waits for the element matching the locator's selector with strict mode on.

type MediaType

type MediaType string
const (
	MediaTypeScreen MediaType = "screen"
	MediaTypePrint  MediaType = "print"
)

type Mouse

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

Mouse represents a mouse input device.

func NewMouse

func NewMouse(ctx context.Context, s session, f *Frame, ts *TimeoutSettings, k *Keyboard) *Mouse

NewMouse creates a new mouse.

func (*Mouse) Click

func (m *Mouse) Click(x float64, y float64, opts goja.Value)

Click will trigger a series of MouseMove, MouseDown and MouseUp events in the browser.

func (*Mouse) DblClick

func (m *Mouse) DblClick(x float64, y float64, opts goja.Value)

func (*Mouse) Down

func (m *Mouse) Down(x float64, y float64, opts goja.Value)

Down will trigger a MouseDown event in the browser.

func (*Mouse) Move

func (m *Mouse) Move(x float64, y float64, opts goja.Value)

Move will trigger a MouseMoved event in the browser.

func (*Mouse) Up

func (m *Mouse) Up(x float64, y float64, opts goja.Value)

Up will trigger a MouseUp event in the browser.

type MouseClickOptions

type MouseClickOptions struct {
	Button     string `json:"button"`
	ClickCount int64  `json:"clickCount"`
	Delay      int64  `json:"delay"`
}

func NewMouseClickOptions

func NewMouseClickOptions() *MouseClickOptions

func (*MouseClickOptions) Parse

func (o *MouseClickOptions) Parse(ctx context.Context, opts goja.Value) error

func (*MouseClickOptions) ToMouseDownUpOptions

func (o *MouseClickOptions) ToMouseDownUpOptions() *MouseDownUpOptions

type MouseDblClickOptions

type MouseDblClickOptions struct {
	Button string `json:"button"`
	Delay  int64  `json:"delay"`
}

func NewMouseDblClickOptions

func NewMouseDblClickOptions() *MouseDblClickOptions

func (*MouseDblClickOptions) Parse

func (o *MouseDblClickOptions) Parse(ctx context.Context, opts goja.Value) error

func (*MouseDblClickOptions) ToMouseDownUpOptions

func (o *MouseDblClickOptions) ToMouseDownUpOptions() *MouseDownUpOptions

type MouseDownUpOptions

type MouseDownUpOptions struct {
	Button     string `json:"button"`
	ClickCount int64  `json:"clickCount"`
}

func NewMouseDownUpOptions

func NewMouseDownUpOptions() *MouseDownUpOptions

func (*MouseDownUpOptions) Parse

func (o *MouseDownUpOptions) Parse(ctx context.Context, opts goja.Value) error

type MouseMoveOptions

type MouseMoveOptions struct {
	Steps int64 `json:"steps"`
}

func NewMouseMoveOptions

func NewMouseMoveOptions() *MouseMoveOptions

func (*MouseMoveOptions) Parse

func (o *MouseMoveOptions) Parse(ctx context.Context, opts goja.Value) error
type NavigationEvent struct {
	// contains filtered or unexported fields
}

NavigationEvent is emitted when we receive a Page.frameNavigated or Page.navigatedWithinDocument CDP event. See: - https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-frameNavigated - https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-navigatedWithinDocument

type NetworkManager

type NetworkManager struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

NetworkManager manages all frames in HTML document.

func NewNetworkManager

func NewNetworkManager(
	ctx context.Context, s session, fm *FrameManager, parent *NetworkManager,
) (*NetworkManager, error)

NewNetworkManager creates a new network manager.

func (*NetworkManager) Authenticate

func (m *NetworkManager) Authenticate(credentials *Credentials)

Authenticate sets HTTP authentication credentials to use.

func (*NetworkManager) ExtraHTTPHeaders

func (m *NetworkManager) ExtraHTTPHeaders() goja.Value

ExtraHTTPHeaders returns the currently set extra HTTP request headers.

func (*NetworkManager) SetCacheEnabled

func (m *NetworkManager) SetCacheEnabled(enabled bool)

SetCacheEnabled toggles cache on/off.

func (*NetworkManager) SetExtraHTTPHeaders

func (m *NetworkManager) SetExtraHTTPHeaders(headers network.Headers)

SetExtraHTTPHeaders sets extra HTTP request headers to be sent with every request.

func (*NetworkManager) SetOfflineMode

func (m *NetworkManager) SetOfflineMode(offline bool)

SetOfflineMode toggles offline mode on/off.

func (*NetworkManager) SetUserAgent

func (m *NetworkManager) SetUserAgent(userAgent string)

SetUserAgent overrides the browser user agent string.

type Page

type Page struct {
	BaseEventEmitter

	Keyboard    *Keyboard    `js:"keyboard"`    // Public JS API
	Mouse       *Mouse       `js:"mouse"`       // Public JS API
	Touchscreen *Touchscreen `js:"touchscreen"` // Public JS API
	// contains filtered or unexported fields
}

Page stores Page/tab related context.

func NewPage

func NewPage(
	ctx context.Context,
	s session,
	bctx *BrowserContext,
	tid target.ID,
	opener *Page,
	bp bool,
	logger *log.Logger,
) (*Page, error)

NewPage creates a new browser page context.

func (*Page) AddInitScript

func (p *Page) AddInitScript(script goja.Value, arg goja.Value)

AddInitScript adds script to run in all new frames.

func (*Page) AddScriptTag

func (p *Page) AddScriptTag(opts goja.Value)

func (*Page) AddStyleTag

func (p *Page) AddStyleTag(opts goja.Value)

func (*Page) BringToFront added in v0.1.2

func (p *Page) BringToFront()

BringToFront activates the browser tab for this page.

func (*Page) Check

func (p *Page) Check(selector string, opts goja.Value)

Check checks an element matching the provided selector.

func (*Page) Click

func (p *Page) Click(selector string, opts goja.Value) *goja.Promise

Click clicks an element matching provided selector.

func (*Page) Close

func (p *Page) Close(opts goja.Value)

Close closes the page.

func (*Page) Content

func (p *Page) Content() string

Content returns the HTML content of the page.

func (*Page) Context

func (p *Page) Context() api.BrowserContext

Context closes the page.

func (*Page) Dblclick

func (p *Page) Dblclick(selector string, opts goja.Value)

Dblclick double clicks an element matching provided selector.

func (*Page) DispatchEvent

func (p *Page) DispatchEvent(selector string, typ string, eventInit goja.Value, opts goja.Value)

func (*Page) DragAndDrop

func (p *Page) DragAndDrop(source string, target string, opts goja.Value)

func (*Page) EmulateMedia

func (p *Page) EmulateMedia(opts goja.Value)

func (*Page) EmulateVisionDeficiency

func (p *Page) EmulateVisionDeficiency(typ string)

EmulateVisionDeficiency activates/deactivates emulation of a vision deficiency.

func (*Page) Evaluate

func (p *Page) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}

Evaluate runs JS code within the execution context of the main frame of the page.

func (*Page) EvaluateHandle

func (p *Page) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) api.JSHandle

func (*Page) ExposeBinding

func (p *Page) ExposeBinding(name string, callback goja.Callable, opts goja.Value)

func (*Page) ExposeFunction

func (p *Page) ExposeFunction(name string, callback goja.Callable)

func (*Page) Fill

func (p *Page) Fill(selector string, value string, opts goja.Value)

func (*Page) Focus

func (p *Page) Focus(selector string, opts goja.Value)

func (*Page) Frame

func (p *Page) Frame(frameSelector goja.Value) api.Frame

func (*Page) Frames

func (p *Page) Frames() []api.Frame

Frames returns a list of frames on the page.

func (*Page) GetAttribute

func (p *Page) GetAttribute(selector string, name string, opts goja.Value) goja.Value

func (*Page) GoBack

func (p *Page) GoBack(opts goja.Value) api.Response

func (*Page) GoForward

func (p *Page) GoForward(opts goja.Value) api.Response

func (*Page) Goto

func (p *Page) Goto(url string, opts goja.Value) api.Response

Goto will navigate the page to the specified URL and return a HTTP response object.

func (*Page) Hover

func (p *Page) Hover(selector string, opts goja.Value)

func (*Page) InnerHTML

func (p *Page) InnerHTML(selector string, opts goja.Value) string

func (*Page) InnerText

func (p *Page) InnerText(selector string, opts goja.Value) string

func (*Page) InputValue

func (p *Page) InputValue(selector string, opts goja.Value) string

func (*Page) IsChecked

func (p *Page) IsChecked(selector string, opts goja.Value) bool

IsChecked returns true if the first element that matches the selector is checked. Otherwise, returns false.

func (*Page) IsClosed

func (p *Page) IsClosed() bool

func (*Page) IsDisabled

func (p *Page) IsDisabled(selector string, opts goja.Value) bool

func (*Page) IsEditable

func (p *Page) IsEditable(selector string, opts goja.Value) bool

func (*Page) IsEnabled

func (p *Page) IsEnabled(selector string, opts goja.Value) bool

func (*Page) IsHidden

func (p *Page) IsHidden(selector string, opts goja.Value) bool

func (*Page) IsVisible

func (p *Page) IsVisible(selector string, opts goja.Value) bool

func (*Page) Locator added in v0.4.0

func (p *Page) Locator(selector string, opts goja.Value) api.Locator

Locator creates and returns a new locator for this page (main frame).

func (*Page) MainFrame

func (p *Page) MainFrame() api.Frame

MainFrame returns the main frame on the page.

func (*Page) Opener

func (p *Page) Opener() api.Page

Opener returns the opener of the target.

func (*Page) Pause

func (p *Page) Pause()

func (*Page) Pdf

func (p *Page) Pdf(opts goja.Value) goja.ArrayBuffer

func (*Page) Press

func (p *Page) Press(selector string, key string, opts goja.Value)

func (*Page) Query

func (p *Page) Query(selector string) api.ElementHandle

func (*Page) QueryAll

func (p *Page) QueryAll(selector string) []api.ElementHandle

func (*Page) Reload

func (p *Page) Reload(opts goja.Value) api.Response

Reload will reload the current page.

func (*Page) Route

func (p *Page) Route(url goja.Value, handler goja.Callable)

func (*Page) Screenshot

func (p *Page) Screenshot(opts goja.Value) goja.ArrayBuffer

Screenshot will instruct Chrome to save a screenshot of the current page and save it to specified file.

func (*Page) SelectOption

func (p *Page) SelectOption(selector string, values goja.Value, opts goja.Value) []string

func (*Page) SetContent

func (p *Page) SetContent(html string, opts goja.Value)

func (*Page) SetDefaultNavigationTimeout

func (p *Page) SetDefaultNavigationTimeout(timeout int64)

SetDefaultNavigationTimeout sets the default navigation timeout in milliseconds.

func (*Page) SetDefaultTimeout

func (p *Page) SetDefaultTimeout(timeout int64)

SetDefaultTimeout sets the default maximum timeout in milliseconds.

func (*Page) SetExtraHTTPHeaders

func (p *Page) SetExtraHTTPHeaders(headers map[string]string)

SetExtraHTTPHeaders sets default HTTP headers for page and whole frame hierarchy.

func (*Page) SetInputFiles

func (p *Page) SetInputFiles(selector string, files goja.Value, opts goja.Value)

func (*Page) SetViewportSize

func (p *Page) SetViewportSize(viewportSize goja.Value)

SetViewportSize will update the viewport width and height.

func (*Page) Tap

func (p *Page) Tap(selector string, opts goja.Value)

func (*Page) TextContent

func (p *Page) TextContent(selector string, opts goja.Value) string

func (*Page) Title

func (p *Page) Title() string

func (*Page) Type

func (p *Page) Type(selector string, text string, opts goja.Value)

func (*Page) URL

func (p *Page) URL() string

URL returns the location of the page.

func (*Page) Uncheck

func (p *Page) Uncheck(selector string, opts goja.Value)

Uncheck unchecks an element matching the provided selector.

func (*Page) Unroute

func (p *Page) Unroute(url goja.Value, handler goja.Callable)

func (*Page) Video

func (p *Page) Video() api.Video

Video returns information of recorded video.

func (*Page) ViewportSize

func (p *Page) ViewportSize() map[string]float64

ViewportSize will return information on the viewport width and height.

func (*Page) WaitForEvent

func (p *Page) WaitForEvent(event string, optsOrPredicate goja.Value) interface{}

WaitForEvent waits for the specified event to trigger.

func (*Page) WaitForFunction

func (p *Page) WaitForFunction(fn, opts goja.Value, args ...goja.Value) *goja.Promise

WaitForFunction waits for the given predicate to return a truthy value.

func (*Page) WaitForLoadState

func (p *Page) WaitForLoadState(state string, opts goja.Value)

WaitForLoadState waits for the specified page life cycle event.

func (*Page) WaitForNavigation

func (p *Page) WaitForNavigation(opts goja.Value) *goja.Promise

WaitForNavigation waits for the given navigation lifecycle event to happen.

func (*Page) WaitForRequest

func (p *Page) WaitForRequest(urlOrPredicate, opts goja.Value) api.Request

func (*Page) WaitForResponse

func (p *Page) WaitForResponse(urlOrPredicate, opts goja.Value) api.Response

func (*Page) WaitForSelector

func (p *Page) WaitForSelector(selector string, opts goja.Value) api.ElementHandle

WaitForSelector waits for the given selector to match the waiting criteria.

func (*Page) WaitForTimeout

func (p *Page) WaitForTimeout(timeout int64)

WaitForTimeout waits the specified number of milliseconds.

func (*Page) Workers

func (p *Page) Workers() []api.Worker

Workers returns all WebWorkers of page.

type PageEmulateMediaOptions

type PageEmulateMediaOptions struct {
	ColorScheme   ColorScheme   `json:"colorScheme"`
	Media         MediaType     `json:"media"`
	ReducedMotion ReducedMotion `json:"reducedMotion"`
}

func NewPageEmulateMediaOptions

func NewPageEmulateMediaOptions(defaultMedia MediaType, defaultColorScheme ColorScheme, defaultReducedMotion ReducedMotion) *PageEmulateMediaOptions

func (*PageEmulateMediaOptions) Parse

func (o *PageEmulateMediaOptions) Parse(ctx context.Context, opts goja.Value) error

type PageReloadOptions

type PageReloadOptions struct {
	WaitUntil LifecycleEvent `json:"waitUntil"`
	Timeout   time.Duration  `json:"timeout"`
}

func NewPageReloadOptions

func NewPageReloadOptions(defaultWaitUntil LifecycleEvent, defaultTimeout time.Duration) *PageReloadOptions

func (*PageReloadOptions) Parse

func (o *PageReloadOptions) Parse(ctx context.Context, opts goja.Value) error

type PageScreenshotOptions

type PageScreenshotOptions struct {
	Clip           *page.Viewport `json:"clip"`
	Path           string         `json:"path"`
	Format         ImageFormat    `json:"format"`
	FullPage       bool           `json:"fullPage"`
	OmitBackground bool           `json:"omitBackground"`
	Quality        int64          `json:"quality"`
}

func NewPageScreenshotOptions

func NewPageScreenshotOptions() *PageScreenshotOptions

func (*PageScreenshotOptions) Parse

func (o *PageScreenshotOptions) Parse(ctx context.Context, opts goja.Value) error

type PollingType

type PollingType int
const (
	PollingRaf PollingType = iota
	PollingMutation
	PollingInterval
)

func (PollingType) MarshalJSON

func (p PollingType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (PollingType) String

func (p PollingType) String() string

func (*PollingType) UnmarshalJSON

func (p *PollingType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

type Position

type Position struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type ProxyOptions

type ProxyOptions struct {
	Server   string
	Bypass   string
	Username string
	Password string
}

type Rect

type Rect struct {
	X      float64 `js:"x"`
	Y      float64 `js:"y"`
	Width  float64 `js:"width"`
	Height float64 `js:"height"`
}

type ReducedMotion

type ReducedMotion string

ReducedMotion represents a browser reduce-motion setting.

const (
	ReducedMotionReduce       ReducedMotion = "reduce"
	ReducedMotionNoPreference ReducedMotion = "no-preference"
)

Valid reduce-motion options.

func (ReducedMotion) MarshalJSON

func (r ReducedMotion) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted JSON string.

func (ReducedMotion) String

func (r ReducedMotion) String() string

func (*ReducedMotion) UnmarshalJSON

func (r *ReducedMotion) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted JSON string to the enum value.

type RemoteAddress

type RemoteAddress struct {
	IPAddress string `json:"ipAddress"`
	Port      int64  `json:"port"`
}

RemoteAddress contains informationa about a remote target.

type Request

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

Request represents a browser HTTP request.

func NewRequest

func NewRequest(
	ctx context.Context, event *network.EventRequestWillBeSent, f *Frame,
	redirectChain []*Request, interceptionID string, allowInterception bool,
) (*Request, error)

NewRequest creates a new HTTP request.

func (*Request) AllHeaders

func (r *Request) AllHeaders() map[string]string

func (*Request) Failure

func (r *Request) Failure() goja.Value

func (*Request) Frame

func (r *Request) Frame() api.Frame

Frame returns the frame within which the request was made.

func (*Request) HeaderValue

func (r *Request) HeaderValue(name string) goja.Value

func (*Request) Headers

func (r *Request) Headers() map[string]string

Headers returns the request headers.

func (*Request) HeadersArray

func (r *Request) HeadersArray() []api.HTTPHeader

func (*Request) IsNavigationRequest

func (r *Request) IsNavigationRequest() bool

IsNavigationRequest returns whether this was a navigation request or not.

func (*Request) Method

func (r *Request) Method() string

Method returns the request method.

func (*Request) PostData

func (r *Request) PostData() string

PostData returns the request post data, if any.

func (*Request) PostDataBuffer

func (r *Request) PostDataBuffer() goja.ArrayBuffer

PostDataBuffer returns the request post data as an ArrayBuffer.

func (*Request) PostDataJSON

func (r *Request) PostDataJSON() string

PostDataJSON returns the request post data as a JS object.

func (*Request) RedirectedFrom

func (r *Request) RedirectedFrom() api.Request

func (*Request) RedirectedTo

func (r *Request) RedirectedTo() api.Request

func (*Request) ResourceType

func (r *Request) ResourceType() string

ResourceType returns the request resource type.

func (*Request) Response

func (r *Request) Response() api.Response

Response returns the response for the request, if received.

func (*Request) Size

func (r *Request) Size() api.HTTPMessageSize

func (*Request) Timing

func (r *Request) Timing() goja.Value

func (*Request) URL

func (r *Request) URL() string

URL returns the request URL.

type ResourceTiming

type ResourceTiming struct {
	StartTime             float64 `js:"startTime"`
	DomainLookupStart     float64 `js:"domainLookupStart"`
	DomainLookupEnd       float64 `js:"domainLookupEnd"`
	ConnectStart          float64 `js:"connectStart"`
	SecureConnectionStart float64 `js:"secureConnectionStart"`
	ConnectEnd            float64 `js:"connectEnd"`
	RequestStart          float64 `js:"requestStart"`
	ResponseStart         float64 `js:"responseStart"`
	ResponseEnd           float64 `js:"responseEnd"`
}

type Response

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

Response represents a browser HTTP response.

func NewHTTPResponse

func NewHTTPResponse(ctx context.Context, req *Request, resp *network.Response, timestamp *cdp.MonotonicTime) *Response

NewHTTPResponse creates a new HTTP response.

func (*Response) AllHeaders

func (r *Response) AllHeaders() map[string]string

func (*Response) Body

func (r *Response) Body() goja.ArrayBuffer

Body returns the response body as a binary buffer.

func (*Response) Finished

func (r *Response) Finished() bool

Finished waits for response to finish, return error if request failed.

func (*Response) Frame

func (r *Response) Frame() api.Frame

Frame returns the frame within which the response was received.

func (*Response) FromCache

func (r *Response) FromCache() bool

FromCache returns whether this response was served from disk cache.

func (*Response) FromPrefetchCache

func (r *Response) FromPrefetchCache() bool

FromPrefetchCache returns whether this response was served from prefetch cache.

func (*Response) FromServiceWorker

func (r *Response) FromServiceWorker() bool

FromServiceWorker returns whether this response was served by a service worker.

func (*Response) HeaderValue

func (r *Response) HeaderValue(name string) goja.Value

func (*Response) HeaderValues

func (r *Response) HeaderValues(name string) []string

func (*Response) Headers

func (r *Response) Headers() map[string]string

Headers returns the response headers.

func (*Response) HeadersArray

func (r *Response) HeadersArray() []api.HTTPHeader

func (*Response) JSON

func (r *Response) JSON() goja.Value

JSON returns the response body as JSON data.

func (*Response) Ok

func (r *Response) Ok() bool

Ok returns true if status code of response if considered ok, otherwise returns false.

func (*Response) Request

func (r *Response) Request() api.Request

Request returns the request that led to this response.

func (*Response) SecurityDetails

func (r *Response) SecurityDetails() goja.Value

func (*Response) ServerAddr

func (r *Response) ServerAddr() goja.Value

ServerAddr returns the remote address of the server.

func (*Response) Size

func (r *Response) Size() api.HTTPMessageSize

func (*Response) Status

func (r *Response) Status() int64

Status returns the response status code.

func (*Response) StatusText

func (r *Response) StatusText() string

StatusText returns the response status text.

func (*Response) Text

func (r *Response) Text() string

Text returns the response body as a string.

func (*Response) URL

func (r *Response) URL() string

URL returns the request URL.

type Screen

type Screen struct {
	Width  int64 `js:"width"`
	Height int64 `js:"height"`
}

Screen represents a device screen.

func (*Screen) Parse

func (s *Screen) Parse(ctx context.Context, screen goja.Value) error

type ScrollIntoViewOptions added in v0.3.0

type ScrollIntoViewOptions struct {
	// Block defines vertical alignment.
	// One of start, center, end, or nearest.
	// Defaults to start.
	Block ScrollPosition `json:"block"`

	// Inline defines horizontal alignment.
	// One of start, center, end, or nearest.
	// Defaults to nearest.
	Inline ScrollPosition `json:"inline"`
}

ScrollIntoViewOptions change the behavior of ScrollIntoView. See: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

type ScrollPosition added in v0.3.0

type ScrollPosition string

ScrollPosition is a parameter for scrolling an element.

const (
	// ScrollPositionStart scrolls an element at the top of its parent.
	ScrollPositionStart ScrollPosition = "start"
	// ScrollPositionCenter scrolls an element at the center of its parent.
	ScrollPositionCenter ScrollPosition = "center"
	// ScrollPositionEnd scrolls an element at the end of its parent.
	ScrollPositionEnd ScrollPosition = "end"
	// ScrollPositionNearest scrolls an element at the nearest position of its parent.
	ScrollPositionNearest ScrollPosition = "nearest"
)

type SecurityDetails

type SecurityDetails struct {
	SubjectName string   `json:"subjectName"`
	Issuer      string   `json:"issuer"`
	ValidFrom   int64    `json:"validFrom"`
	ValidTo     int64    `json:"validTo"`
	Protocol    string   `json:"protocol"`
	SANList     []string `json:"sanList"`
}

SecurityDetails contains informationa about the security details of a TLS connection.

type SelectOption

type SelectOption struct {
	Value *string `json:"value"`
	Label *string `json:"label"`
	Index *int64  `json:"index"`
}

type Selector

type Selector struct {
	Selector string          `json:"selector"`
	Parts    []*SelectorPart `json:"parts"`

	// By default chained queries resolve to elements matched by the last selector,
	// but a selector can be prefixed with `*` to capture elements resolved by
	// an intermediate selector.
	Capture *int `json:"capture"`
}

func NewSelector

func NewSelector(selector string) (*Selector, error)

type SelectorPart

type SelectorPart struct {
	Name string `json:"name"`
	Body string `json:"body"`
}

type Session

type Session struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

Session represents a CDP session to a target.

func NewSession

func NewSession(
	ctx context.Context, conn *Connection, id target.SessionID, tid target.ID, logger *log.Logger,
) *Session

NewSession creates a new session.

func (*Session) Done added in v0.3.0

func (s *Session) Done() <-chan struct{}

Done returns a channel that is closed when this session is closed.

func (*Session) Execute

func (s *Session) Execute(ctx context.Context, method string, params easyjson.Marshaler, res easyjson.Unmarshaler) error

Execute implements the cdp.Executor interface.

func (*Session) ExecuteWithoutExpectationOnReply

func (s *Session) ExecuteWithoutExpectationOnReply(ctx context.Context, method string, params easyjson.Marshaler, res easyjson.Unmarshaler) error

func (*Session) ID added in v0.2.0

func (s *Session) ID() target.SessionID

ID returns session ID.

func (*Session) TargetID added in v0.3.0

func (s *Session) TargetID() target.ID

TargetID returns session's target ID.

type Size

type Size struct {
	Width  float64 `js:"width"`
	Height float64 `js:"height"`
}

func (*Size) Parse

func (s *Size) Parse(ctx context.Context, viewport goja.Value) error

func (Size) String added in v0.4.0

func (s Size) String() string

type TimeoutSettings

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

TimeoutSettings holds information on timeout settings.

func NewTimeoutSettings

func NewTimeoutSettings(parent *TimeoutSettings) *TimeoutSettings

NewTimeoutSettings creates a new timeout settings object.

type Touchscreen

type Touchscreen struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

Touchscreen represents a touchscreen.

func NewTouchscreen

func NewTouchscreen(ctx context.Context, s session, k *Keyboard) *Touchscreen

NewTouchscreen returns a new TouchScreen.

func (*Touchscreen) Tap

func (t *Touchscreen) Tap(x float64, y float64)

Tap dispatches a tap start and tap end event.

type UnserializableValueError

type UnserializableValueError struct {
	UnserializableValue runtime.UnserializableValue
}

func (UnserializableValueError) Error

func (e UnserializableValueError) Error() string

Error satisfies the builtin error interface.

type Viewport

type Viewport struct {
	Width  int64 `js:"width"`
	Height int64 `js:"height"`
}

Viewport represents a page viewport.

func (*Viewport) Parse

func (v *Viewport) Parse(ctx context.Context, viewport goja.Value) error

Parse viewport details from a given goja viewport value.

func (Viewport) String added in v0.4.0

func (v Viewport) String() string

type Worker

type Worker struct {
	BaseEventEmitter
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(ctx context.Context, s session, id target.ID, url string) (*Worker, error)

NewWorker creates a new page viewport.

func (*Worker) Evaluate

func (w *Worker) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}

Evaluate evaluates a page function in the context of the web worker.

func (*Worker) EvaluateHandle

func (w *Worker) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) api.JSHandle

EvaluateHandle evaluates a page function in the context of the web worker and returns a JS handle.

func (*Worker) URL

func (w *Worker) URL() string

URL returns the URL of the web worker.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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