common

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

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

	// Life-cycle consts
	LifeCycleNetworkIdleTimeout time.Duration = 500 * time.Millisecond
)
View Source
const (
	// Browser
	EventBrowserDisconnected string = "disconnected"

	// BrowserContext
	EventBrowserContextClose string = "close"
	EventBrowserContextPage  string = "page"

	// Connection
	EventConnectionClose string = "close"

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

	// Page
	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"

	// Session
	EventSessionClosed string = "close"

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

Variables

View Source
var (
	BrowserDOMContentLoaded     = k6stats.New("browser_dom_content_loaded", k6stats.Trend, k6stats.Time)
	BrowserFirstPaint           = k6stats.New("browser_first_paint", k6stats.Trend, k6stats.Time)
	BrowserFirstContentfulPaint = k6stats.New("browser_first_contentful_paint", k6stats.Trend, k6stats.Time)
	BrowserFirstMeaningfulPaint = k6stats.New("browser_first_meaningful_paint", k6stats.Trend, k6stats.Time)
	BrowserLoaded               = k6stats.New("browser_loaded", k6stats.Trend, k6stats.Time)
)

Functions

func GetDevices

func GetDevices() map[string]Device

func GetProcessID added in v0.1.1

func GetProcessID(ctx context.Context) int

GetProcessID returns the browser process ID from the context.

func NewJSHandle

func NewJSHandle(
	ctx context.Context, session *Session, execCtx *ExecutionContext,
	frame *Frame, remoteObject *runtime.RemoteObject, logger *Logger,
) api.JSHandle

NewJSHandle creates a new JS handle referencing a remote object

func NullLogger

func NullLogger() *logrus.Logger

func WithHooks

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

func WithLaunchOptions

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

func WithProcessID added in v0.1.1

func WithProcessID(ctx context.Context, pid int) context.Context

WithProcessID saves the browser process ID to the 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

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, cancelFn context.CancelFunc, browserProc *BrowserProcess, launchOpts *LaunchOptions, logger *Logger) (*Browser, error)

NewBrowser creates a new browser

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

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) 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 "ingognito" browser context and will not store any data on disk.

func NewBrowserContext

func NewBrowserContext(ctx context.Context, conn *Connection, browser *Browser, id cdp.BrowserContextID, opts *BrowserContextOptions, logger *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

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

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

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, userDataDir string,
) *BrowserProcess

func (*BrowserProcess) AttachLogger added in v0.1.2

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

WithLogger 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 *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"`
}

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 clicks in the center of the element

func (*ElementHandle) Click

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

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 clicks in the center of the element

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 ElementHandleActionFn

type ElementHandleActionFn func(context.Context, *ElementHandle) (interface{}, error)

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 ElementHandleHoverOptions

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

func NewElementHandleHoverOptions

func NewElementHandleHoverOptions(defaultTimeout time.Duration) *ElementHandleHoverOptions

func (*ElementHandleHoverOptions) Parse

type ElementHandlePointerActionFn

type ElementHandlePointerActionFn func(context.Context, *ElementHandle, *Position) (interface{}, error)

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"
	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, session *Session, frame *Frame,
	id runtime.ExecutionContextID, logger *Logger,
) *ExecutionContext

NewExecutionContext creates a new JS execution context

func (*ExecutionContext) Evaluate

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

Evaluate will evaluate provided page function within this execution context

func (*ExecutionContext) EvaluateHandle

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

EvaluateHandle will evaluate provided page function within this execution context

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 *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)

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 string, typ string, eventInit goja.Value, opts goja.Value)

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 string, value string, opts goja.Value)

func (*Frame) Focus

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

Focus fetches an element with selector and focuses it

func (*Frame) FrameElement

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

func (*Frame) GetAttribute

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

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 hovers an element identified by provided 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

func (*Frame) InnerText

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

func (*Frame) InputValue

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

func (*Frame) IsChecked

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

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

func (*Frame) IsEditable

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

func (*Frame) IsEnabled

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

func (*Frame) IsHidden

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

func (*Frame) IsVisible

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

func (*Frame) LoaderID

func (f *Frame) LoaderID() string

LoaderID returns the ID of the frame that loaded 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 string, key string, opts goja.Value)

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

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)

func (*Frame) TextContent

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

func (*Frame) Title

func (f *Frame) Title() string

func (*Frame) Type

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

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)

func (*Frame) WaitForFunction

func (f *Frame) WaitForFunction(pageFunc goja.Value, opts goja.Value, args ...goja.Value) api.JSHandle

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) api.Response

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 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,
	session *Session, page *Page,
	timeoutSettings *TimeoutSettings,
	logger *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 specifed URL

func (*FrameManager) Page

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

Page returns the page that this frame manager belongs to

func (*FrameManager) WaitForFrameNavigation

func (m *FrameManager) WaitForFrameNavigation(frame *Frame, opts goja.Value) api.Response

WaitForFrameNavigation waits for the given navigation lifecycle event to happen

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, session *Session, page *Page, parent *FrameSession,
	targetID target.ID, logger *Logger,
) (_ *FrameSession, err error)

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

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, session *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) 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

type Logger

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

func NewLogger

func NewLogger(ctx context.Context, logger *logrus.Logger, debugOverride bool, categoryFilter *regexp.Regexp) *Logger

func NewNullLogger added in v0.1.3

func NewNullLogger() *Logger

func (*Logger) DebugMode added in v0.1.2

func (l *Logger) DebugMode() bool

DebugMode returns true if the logger level is set to Debug or higher.

func (*Logger) Debugf

func (l *Logger) Debugf(category string, msg string, args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(category string, msg string, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(category string, msg string, args ...interface{})

func (*Logger) Logf

func (l *Logger) Logf(level logrus.Level, category string, msg string, args ...interface{})

func (*Logger) ReportCaller added in v0.1.2

func (l *Logger) ReportCaller()

ReportCaller adds source file and function names to the log entries.

func (*Logger) SetLevel added in v0.1.2

func (l *Logger) SetLevel(level string) error

SetLevel sets the logger level from a level string. Accepted values:

func (*Logger) Tracef added in v0.1.2

func (l *Logger) Tracef(category string, msg string, args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(category string, msg string, args ...interface{})

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, session *Session, frame *Frame, timeoutSettings *TimeoutSettings, keyboard *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
}

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, session *Session, manager *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,
	session *Session,
	browserCtx *BrowserContext,
	targetID target.ID,
	opener *Page,
	backgroundPage bool,
	logger *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 provided selector

func (*Page) Click

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

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

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) 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)

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(pageFunc goja.Value, arg goja.Value, opts goja.Value) api.JSHandle

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) api.Response

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

ServerAdd 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"`
}

Viewport represents a device screen

func (*Screen) Parse

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

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 *Logger) *Session

NewSession creates a new session

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

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

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, session *Session, keyboard *Keyboard) *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

type Worker

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

Worker represents a WebWorker

func NewWorker

func NewWorker(ctx context.Context, session *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

Jump to

Keyboard shortcuts

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