Documentation ¶
Index ¶
- Constants
- func GetDevices() map[string]Device
- func NewJSHandle(ctx context.Context, s session, ectx *ExecutionContext, f *Frame, ...) jsHandle
- func TrimQuotes(s string) string
- func WithHooks(ctx context.Context, hooks *Hooks) context.Context
- func WithLaunchOptions(ctx context.Context, opts *LaunchOptions) context.Context
- type Action
- type ActionFunc
- type Barrier
- type BaseEventEmitter
- type BaseJSHandle
- func (h *BaseJSHandle) AsElement() api.ElementHandle
- func (h *BaseJSHandle) Dispose()
- func (h *BaseJSHandle) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}
- func (h *BaseJSHandle) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) api.JSHandle
- func (h *BaseJSHandle) GetProperties() map[string]api.JSHandle
- func (h *BaseJSHandle) GetProperty(propertyName string) api.JSHandle
- func (h *BaseJSHandle) JSONValue() goja.Value
- func (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID
- type BigIntParseError
- type Browser
- func (b *Browser) Close()
- func (b *Browser) Contexts() []api.BrowserContext
- func (b *Browser) IsConnected() bool
- func (b *Browser) NewContext(opts goja.Value) api.BrowserContext
- func (b *Browser) NewPage(opts goja.Value) api.Page
- func (b *Browser) On(event string) *goja.Promise
- func (b *Browser) UserAgent() string
- func (b *Browser) Version() string
- type BrowserContext
- func (b *BrowserContext) AddCookies(cookies goja.Value)
- func (b *BrowserContext) AddInitScript(script goja.Value, arg goja.Value)
- func (b *BrowserContext) Browser() api.Browser
- func (b *BrowserContext) ClearCookies()
- func (b *BrowserContext) ClearPermissions()
- func (b *BrowserContext) Close()
- func (b *BrowserContext) Cookies() []goja.Object
- func (b *BrowserContext) ExposeBinding(name string, callback goja.Callable, opts goja.Value)
- func (b *BrowserContext) ExposeFunction(name string, callback goja.Callable)
- func (b *BrowserContext) GrantPermissions(permissions []string, opts goja.Value)
- func (b *BrowserContext) NewCDPSession() api.CDPSession
- func (b *BrowserContext) NewPage() api.Page
- func (b *BrowserContext) Pages() []api.Page
- func (b *BrowserContext) Route(url goja.Value, handler goja.Callable)
- func (b *BrowserContext) SetDefaultNavigationTimeout(timeout int64)
- func (b *BrowserContext) SetDefaultTimeout(timeout int64)
- func (b *BrowserContext) SetExtraHTTPHeaders(headers map[string]string)
- func (b *BrowserContext) SetGeolocation(geolocation goja.Value)
- func (b *BrowserContext) SetHTTPCredentials(httpCredentials goja.Value)deprecated
- func (b *BrowserContext) SetOffline(offline bool)
- func (b *BrowserContext) StorageState(opts goja.Value)
- func (b *BrowserContext) Unroute(url goja.Value, handler goja.Callable)
- func (b *BrowserContext) WaitForEvent(event string, optsOrPredicate goja.Value) interface{}
- type BrowserContextOptions
- type BrowserProcess
- type ColorScheme
- type Connection
- type Credentials
- type DOMElementState
- type Device
- type DocumentInfo
- type ElementHandle
- func (h *ElementHandle) AsElement() api.ElementHandle
- func (h *ElementHandle) BoundingBox() *api.Rect
- func (h *ElementHandle) Check(opts goja.Value)
- func (h *ElementHandle) Click(opts goja.Value) *goja.Promise
- func (h *ElementHandle) ContentFrame() api.Frame
- func (h *ElementHandle) Dblclick(opts goja.Value)
- func (h *ElementHandle) DispatchEvent(typ string, eventInit goja.Value)
- func (h *ElementHandle) Fill(value string, opts goja.Value)
- func (h *ElementHandle) Focus()
- func (h *ElementHandle) GetAttribute(name string) goja.Value
- func (h *ElementHandle) Hover(opts goja.Value)
- func (h *ElementHandle) InnerHTML() string
- func (h *ElementHandle) InnerText() string
- func (h *ElementHandle) InputValue(opts goja.Value) string
- func (h *ElementHandle) IsChecked() bool
- func (h *ElementHandle) IsDisabled() bool
- func (h *ElementHandle) IsEditable() bool
- func (h *ElementHandle) IsEnabled() bool
- func (h *ElementHandle) IsHidden() bool
- func (h *ElementHandle) IsVisible() bool
- func (h *ElementHandle) OwnerFrame() api.Frame
- func (h *ElementHandle) Press(key string, opts goja.Value)
- func (h *ElementHandle) Query(selector string) api.ElementHandle
- func (h *ElementHandle) QueryAll(selector string) []api.ElementHandle
- func (h *ElementHandle) Screenshot(opts goja.Value) goja.ArrayBuffer
- func (h *ElementHandle) ScrollIntoViewIfNeeded(opts goja.Value)
- func (h *ElementHandle) SelectOption(values goja.Value, opts goja.Value) []string
- func (h *ElementHandle) SelectText(opts goja.Value)
- func (h *ElementHandle) SetChecked(checked bool, opts goja.Value)
- func (h *ElementHandle) SetInputFiles(files goja.Value, opts goja.Value)
- func (h *ElementHandle) Tap(opts goja.Value)
- func (h *ElementHandle) TextContent() string
- func (h *ElementHandle) Type(text string, opts goja.Value)
- func (h *ElementHandle) Uncheck(opts goja.Value)
- func (h *ElementHandle) WaitForElementState(state string, opts goja.Value)
- func (h *ElementHandle) WaitForSelector(selector string, opts goja.Value) api.ElementHandle
- type ElementHandleBaseOptions
- type ElementHandleBasePointerOptions
- type ElementHandleCheckOptions
- type ElementHandleClickOptions
- type ElementHandleDblclickOptions
- type ElementHandleDispatchEventOptions
- type ElementHandleHoverOptions
- type ElementHandlePressOptions
- type ElementHandleScreenshotOptions
- type ElementHandleSetCheckedOptions
- type ElementHandleTapOptions
- type ElementHandleTypeOptions
- type ElementHandleWaitForElementStateOptions
- type EmulatedSize
- type Error
- type Event
- type EventEmitter
- type ExecutionContext
- func (e *ExecutionContext) Eval(apiCtx context.Context, js goja.Value, args ...goja.Value) (interface{}, error)
- func (e *ExecutionContext) EvalHandle(apiCtx context.Context, js goja.Value, args ...goja.Value) (api.JSHandle, error)
- func (e *ExecutionContext) Frame() *Frame
- func (e *ExecutionContext) ID() runtime.ExecutionContextID
- type FieldNameMapper
- type Frame
- func (f *Frame) AddScriptTag(opts goja.Value)
- func (f *Frame) AddStyleTag(opts goja.Value)
- func (f *Frame) Check(selector string, opts goja.Value)
- func (f *Frame) ChildFrames() []api.Frame
- func (f *Frame) Click(selector string, opts goja.Value) *goja.Promise
- func (f *Frame) Content() string
- func (f *Frame) Dblclick(selector string, opts goja.Value)
- func (f *Frame) DispatchEvent(selector, typ string, eventInit, opts goja.Value)
- func (f *Frame) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}
- func (f *Frame) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) (handle api.JSHandle)
- func (f *Frame) Fill(selector, value string, opts goja.Value)
- func (f *Frame) Focus(selector string, opts goja.Value)
- func (f *Frame) FrameElement() api.ElementHandle
- func (f *Frame) GetAttribute(selector, name string, opts goja.Value) goja.Value
- func (f *Frame) Goto(url string, opts goja.Value) api.Response
- func (f *Frame) Hover(selector string, opts goja.Value)
- func (f *Frame) ID() string
- func (f *Frame) InnerHTML(selector string, opts goja.Value) string
- func (f *Frame) InnerText(selector string, opts goja.Value) string
- func (f *Frame) InputValue(selector string, opts goja.Value) string
- func (f *Frame) IsChecked(selector string, opts goja.Value) bool
- func (f *Frame) IsDetached() bool
- func (f *Frame) IsDisabled(selector string, opts goja.Value) bool
- func (f *Frame) IsEditable(selector string, opts goja.Value) bool
- func (f *Frame) IsEnabled(selector string, opts goja.Value) bool
- func (f *Frame) IsHidden(selector string, opts goja.Value) bool
- func (f *Frame) IsVisible(selector string, opts goja.Value) bool
- func (f *Frame) LoaderID() string
- func (f *Frame) Locator(selector string, opts goja.Value) api.Locator
- func (f *Frame) Name() string
- func (f *Frame) Page() api.Page
- func (f *Frame) ParentFrame() api.Frame
- func (f *Frame) Press(selector, key string, opts goja.Value)
- func (f *Frame) Query(selector string) api.ElementHandle
- func (f *Frame) QueryAll(selector string) []api.ElementHandle
- func (f *Frame) SelectOption(selector string, values goja.Value, opts goja.Value) []string
- func (f *Frame) SetContent(html string, opts goja.Value)
- func (f *Frame) SetInputFiles(selector string, files goja.Value, opts goja.Value)
- func (f *Frame) Tap(selector string, opts goja.Value)
- func (f *Frame) TextContent(selector string, opts goja.Value) string
- func (f *Frame) Title() string
- func (f *Frame) Type(selector, text string, opts goja.Value)
- func (f *Frame) URL() string
- func (f *Frame) Uncheck(selector string, opts goja.Value)
- func (f *Frame) WaitForFunction(fn goja.Value, opts goja.Value, jsArgs ...goja.Value) *goja.Promise
- func (f *Frame) WaitForLoadState(state string, opts goja.Value)
- func (f *Frame) WaitForNavigation(opts goja.Value) *goja.Promise
- func (f *Frame) WaitForSelector(selector string, opts goja.Value) api.ElementHandle
- func (f *Frame) WaitForTimeout(timeout int64)
- type FrameBaseOptions
- type FrameCheckOptions
- type FrameClickOptions
- type FrameDblclickOptions
- type FrameDispatchEventOptions
- type FrameFillOptions
- type FrameGotoOptions
- type FrameHoverOptions
- type FrameInnerHTMLOptions
- type FrameInnerTextOptions
- type FrameInputValueOptions
- type FrameIsCheckedOptions
- type FrameIsDisabledOptions
- type FrameIsEditableOptions
- type FrameIsEnabledOptions
- type FrameIsHiddenOptions
- type FrameIsVisibleOptions
- type FrameManager
- type FramePressOptions
- type FrameSelectOptionOptions
- type FrameSession
- type FrameSetContentOptions
- type FrameTapOptions
- type FrameTextContentOptions
- type FrameTypeOptions
- type FrameUncheckOptions
- type FrameWaitForFunctionOptions
- type FrameWaitForLoadStateOptions
- type FrameWaitForNavigationOptions
- type FrameWaitForSelectorOptions
- type Geolocation
- type Hook
- type HookID
- type Hooks
- type ImageFormat
- type Keyboard
- type KeyboardOptions
- type LaunchOptions
- type LaunchPersistentContextOptions
- type LifecycleEvent
- type Locator
- func (l *Locator) Check(opts goja.Value)
- func (l *Locator) Click(opts goja.Value)
- func (l *Locator) Dblclick(opts goja.Value)
- func (l *Locator) DispatchEvent(typ string, eventInit, opts goja.Value)
- func (l *Locator) Fill(value string, opts goja.Value)
- func (l *Locator) Focus(opts goja.Value)
- func (l *Locator) GetAttribute(name string, opts goja.Value) goja.Value
- func (l *Locator) Hover(opts goja.Value)
- func (l *Locator) InnerHTML(opts goja.Value) string
- func (l *Locator) InnerText(opts goja.Value) string
- func (l *Locator) InputValue(opts goja.Value) string
- func (l *Locator) IsChecked(opts goja.Value) bool
- func (l *Locator) IsDisabled(opts goja.Value) bool
- func (l *Locator) IsEditable(opts goja.Value) bool
- func (l *Locator) IsEnabled(opts goja.Value) bool
- func (l *Locator) IsHidden(opts goja.Value) bool
- func (l *Locator) IsVisible(opts goja.Value) bool
- func (l *Locator) Press(key string, opts goja.Value)
- func (l *Locator) SelectOption(values goja.Value, opts goja.Value) []string
- func (l *Locator) Tap(opts goja.Value)
- func (l *Locator) TextContent(opts goja.Value) string
- func (l *Locator) Type(text string, opts goja.Value)
- func (l *Locator) Uncheck(opts goja.Value)
- func (l *Locator) WaitFor(opts goja.Value)
- type MediaType
- type Mouse
- func (m *Mouse) Click(x float64, y float64, opts goja.Value)
- func (m *Mouse) DblClick(x float64, y float64, opts goja.Value)
- func (m *Mouse) Down(x float64, y float64, opts goja.Value)
- func (m *Mouse) Move(x float64, y float64, opts goja.Value)
- func (m *Mouse) Up(x float64, y float64, opts goja.Value)
- type MouseClickOptions
- type MouseDblClickOptions
- type MouseDownUpOptions
- type MouseMoveOptions
- type NavigationEvent
- type NetworkManager
- func (m *NetworkManager) Authenticate(credentials *Credentials)
- func (m *NetworkManager) ExtraHTTPHeaders() goja.Value
- func (m *NetworkManager) SetCacheEnabled(enabled bool)
- func (m *NetworkManager) SetExtraHTTPHeaders(headers network.Headers)
- func (m *NetworkManager) SetOfflineMode(offline bool)
- func (m *NetworkManager) SetUserAgent(userAgent string)
- type Page
- func (p *Page) AddInitScript(script goja.Value, arg goja.Value)
- func (p *Page) AddScriptTag(opts goja.Value)
- func (p *Page) AddStyleTag(opts goja.Value)
- func (p *Page) BringToFront()
- func (p *Page) Check(selector string, opts goja.Value)
- func (p *Page) Click(selector string, opts goja.Value) *goja.Promise
- func (p *Page) Close(opts goja.Value)
- func (p *Page) Content() string
- func (p *Page) Context() api.BrowserContext
- func (p *Page) Dblclick(selector string, opts goja.Value)
- func (p *Page) DispatchEvent(selector string, typ string, eventInit goja.Value, opts goja.Value)
- func (p *Page) DragAndDrop(source string, target string, opts goja.Value)
- func (p *Page) EmulateMedia(opts goja.Value)
- func (p *Page) EmulateVisionDeficiency(typ string)
- func (p *Page) Evaluate(pageFunc goja.Value, args ...goja.Value) interface{}
- func (p *Page) EvaluateHandle(pageFunc goja.Value, args ...goja.Value) api.JSHandle
- func (p *Page) ExposeBinding(name string, callback goja.Callable, opts goja.Value)
- func (p *Page) ExposeFunction(name string, callback goja.Callable)
- func (p *Page) Fill(selector string, value string, opts goja.Value)
- func (p *Page) Focus(selector string, opts goja.Value)
- func (p *Page) Frame(frameSelector goja.Value) api.Frame
- func (p *Page) Frames() []api.Frame
- func (p *Page) GetAttribute(selector string, name string, opts goja.Value) goja.Value
- func (p *Page) GoBack(opts goja.Value) api.Response
- func (p *Page) GoForward(opts goja.Value) api.Response
- func (p *Page) Goto(url string, opts goja.Value) api.Response
- func (p *Page) Hover(selector string, opts goja.Value)
- func (p *Page) InnerHTML(selector string, opts goja.Value) string
- func (p *Page) InnerText(selector string, opts goja.Value) string
- func (p *Page) InputValue(selector string, opts goja.Value) string
- func (p *Page) IsChecked(selector string, opts goja.Value) bool
- func (p *Page) IsClosed() bool
- func (p *Page) IsDisabled(selector string, opts goja.Value) bool
- func (p *Page) IsEditable(selector string, opts goja.Value) bool
- func (p *Page) IsEnabled(selector string, opts goja.Value) bool
- func (p *Page) IsHidden(selector string, opts goja.Value) bool
- func (p *Page) IsVisible(selector string, opts goja.Value) bool
- func (p *Page) Locator(selector string, opts goja.Value) api.Locator
- func (p *Page) MainFrame() api.Frame
- func (p *Page) Opener() api.Page
- func (p *Page) Pause()
- func (p *Page) Pdf(opts goja.Value) goja.ArrayBuffer
- func (p *Page) Press(selector string, key string, opts goja.Value)
- func (p *Page) Query(selector string) api.ElementHandle
- func (p *Page) QueryAll(selector string) []api.ElementHandle
- func (p *Page) Reload(opts goja.Value) api.Response
- func (p *Page) Route(url goja.Value, handler goja.Callable)
- func (p *Page) Screenshot(opts goja.Value) goja.ArrayBuffer
- func (p *Page) SelectOption(selector string, values goja.Value, opts goja.Value) []string
- func (p *Page) SetContent(html string, opts goja.Value)
- func (p *Page) SetDefaultNavigationTimeout(timeout int64)
- func (p *Page) SetDefaultTimeout(timeout int64)
- func (p *Page) SetExtraHTTPHeaders(headers map[string]string)
- func (p *Page) SetInputFiles(selector string, files goja.Value, opts goja.Value)
- func (p *Page) SetViewportSize(viewportSize goja.Value)
- func (p *Page) Tap(selector string, opts goja.Value)
- func (p *Page) TextContent(selector string, opts goja.Value) string
- func (p *Page) Title() string
- func (p *Page) Type(selector string, text string, opts goja.Value)
- func (p *Page) URL() string
- func (p *Page) Uncheck(selector string, opts goja.Value)
- func (p *Page) Unroute(url goja.Value, handler goja.Callable)
- func (p *Page) Video() api.Video
- func (p *Page) ViewportSize() map[string]float64
- func (p *Page) WaitForEvent(event string, optsOrPredicate goja.Value) interface{}
- func (p *Page) WaitForFunction(fn, opts goja.Value, args ...goja.Value) *goja.Promise
- func (p *Page) WaitForLoadState(state string, opts goja.Value)
- func (p *Page) WaitForNavigation(opts goja.Value) *goja.Promise
- func (p *Page) WaitForRequest(urlOrPredicate, opts goja.Value) api.Request
- func (p *Page) WaitForResponse(urlOrPredicate, opts goja.Value) api.Response
- func (p *Page) WaitForSelector(selector string, opts goja.Value) api.ElementHandle
- func (p *Page) WaitForTimeout(timeout int64)
- func (p *Page) Workers() []api.Worker
- type PageEmulateMediaOptions
- type PageReloadOptions
- type PageScreenshotOptions
- type PollingType
- type Position
- type ProxyOptions
- type Rect
- type ReducedMotion
- type RemoteAddress
- type Request
- func (r *Request) AllHeaders() map[string]string
- func (r *Request) Failure() goja.Value
- func (r *Request) Frame() api.Frame
- func (r *Request) HeaderValue(name string) goja.Value
- func (r *Request) Headers() map[string]string
- func (r *Request) HeadersArray() []api.HTTPHeader
- func (r *Request) IsNavigationRequest() bool
- func (r *Request) Method() string
- func (r *Request) PostData() string
- func (r *Request) PostDataBuffer() goja.ArrayBuffer
- func (r *Request) PostDataJSON() string
- func (r *Request) RedirectedFrom() api.Request
- func (r *Request) RedirectedTo() api.Request
- func (r *Request) ResourceType() string
- func (r *Request) Response() api.Response
- func (r *Request) Size() api.HTTPMessageSize
- func (r *Request) Timing() goja.Value
- func (r *Request) URL() string
- type ResourceTiming
- type Response
- func (r *Response) AllHeaders() map[string]string
- func (r *Response) Body() goja.ArrayBuffer
- func (r *Response) Finished() bool
- func (r *Response) Frame() api.Frame
- func (r *Response) FromCache() bool
- func (r *Response) FromPrefetchCache() bool
- func (r *Response) FromServiceWorker() bool
- func (r *Response) HeaderValue(name string) goja.Value
- func (r *Response) HeaderValues(name string) []string
- func (r *Response) Headers() map[string]string
- func (r *Response) HeadersArray() []api.HTTPHeader
- func (r *Response) JSON() goja.Value
- func (r *Response) Ok() bool
- func (r *Response) Request() api.Request
- func (r *Response) SecurityDetails() goja.Value
- func (r *Response) ServerAddr() goja.Value
- func (r *Response) Size() api.HTTPMessageSize
- func (r *Response) Status() int64
- func (r *Response) StatusText() string
- func (r *Response) Text() string
- func (r *Response) URL() string
- type Screen
- type ScrollIntoViewOptions
- type ScrollPosition
- type SecurityDetails
- type SelectOption
- type Selector
- type SelectorPart
- type Session
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Execute(ctx context.Context, method string, params easyjson.Marshaler, ...) error
- func (s *Session) ExecuteWithoutExpectationOnReply(ctx context.Context, method string, params easyjson.Marshaler, ...) error
- func (s *Session) ID() target.SessionID
- func (s *Session) TargetID() target.ID
- type Size
- type TimeoutSettings
- type Touchscreen
- type UnserializableValueError
- type Viewport
- type Worker
Constants ¶
const ( BrowserStateOpen int64 = iota BrowserStateClosing BrowserStateClosed )
const ( DefaultLocale string = "en-US" DefaultScreenWidth int64 = 1280 DefaultScreenHeight int64 = 720 DefaultTimeout time.Duration = 30 * time.Second LifeCycleNetworkIdleTimeout time.Duration = 500 * time.Millisecond )
const ( EventBrowserDisconnected string = "disconnected" EventBrowserContextClose string = "close" EventBrowserContextPage string = "page" EventConnectionClose string = "close" 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" 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" )
const ( ModifierKeyAlt int64 = 1 << iota ModifierKeyControl ModifierKeyMeta ModifierKeyShift )
Variables ¶
This section is empty.
Functions ¶
func GetDevices ¶
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
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 WithLaunchOptions ¶
func WithLaunchOptions(ctx context.Context, opts *LaunchOptions) context.Context
Types ¶
type ActionFunc ¶
ActionFunc is an adapter to allow regular functions to be used as an Action.
type Barrier ¶
type Barrier struct {
// contains filtered or unexported fields
}
func NewBarrier ¶
func NewBarrier() *Barrier
func (*Barrier) AddFrameNavigation ¶
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) 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 ¶
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) Contexts ¶
func (b *Browser) Contexts() []api.BrowserContext
Contexts returns list of browser contexts.
func (*Browser) IsConnected ¶
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) On ¶ added in v0.3.0
On returns a Promise that is resolved when the browser process is disconnected. The only accepted event value is "disconnected".
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 (*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.
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 ¶
NewConnection creates a new browser.
func (*Connection) Close ¶
func (c *Connection) Close(args ...goja.Value)
type Credentials ¶
Credentials holds HTTP authentication credentials.
func NewCredentials ¶
func NewCredentials() *Credentials
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) 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) 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 (*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
type ElementHandleBasePointerOptions ¶
type ElementHandleBasePointerOptions struct { ElementHandleBaseOptions Position *Position `json:"position"` Trial bool `json:"trial"` }
func NewElementHandleBasePointerOptions ¶
func NewElementHandleBasePointerOptions(defaultTimeout time.Duration) *ElementHandleBasePointerOptions
type ElementHandleCheckOptions ¶
type ElementHandleCheckOptions struct {
ElementHandleBasePointerOptions
}
func NewElementHandleCheckOptions ¶
func NewElementHandleCheckOptions(defaultTimeout time.Duration) *ElementHandleCheckOptions
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) 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) 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
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) ToBaseOptions ¶
func (o *ElementHandlePressOptions) ToBaseOptions() *ElementHandleBaseOptions
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
type ElementHandleSetCheckedOptions ¶
type ElementHandleSetCheckedOptions struct { ElementHandleBasePointerOptions Strict bool `json:"strict"` }
func NewElementHandleSetCheckedOptions ¶
func NewElementHandleSetCheckedOptions(defaultTimeout time.Duration) *ElementHandleSetCheckedOptions
type ElementHandleTapOptions ¶
type ElementHandleTapOptions struct { ElementHandleBasePointerOptions Modifiers []string `json:"modifiers"` }
func NewElementHandleTapOptions ¶
func NewElementHandleTapOptions(defaultTimeout time.Duration) *ElementHandleTapOptions
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) ToBaseOptions ¶
func (o *ElementHandleTypeOptions) ToBaseOptions() *ElementHandleBaseOptions
type ElementHandleWaitForElementStateOptions ¶
func NewElementHandleWaitForElementStateOptions ¶
func NewElementHandleWaitForElementStateOptions(defaultTimeout time.Duration) *ElementHandleWaitForElementStateOptions
type EmulatedSize ¶
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.
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
func (e *ExecutionContext) ID() runtime.ExecutionContextID
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 ¶
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 (*Frame) AddStyleTag ¶
func (*Frame) ChildFrames ¶
ChildFrames returns a list of child frames.
func (*Frame) DispatchEvent ¶
DispatchEvent dispatches an event for the first element matching the selector.
func (*Frame) EvaluateHandle ¶
EvaluateHandle will evaluate provided page function within an execution context.
func (*Frame) FrameElement ¶
func (f *Frame) FrameElement() api.ElementHandle
func (*Frame) GetAttribute ¶
GetAttribute of the first element found that matches the selector.
func (*Frame) Goto ¶
Goto will navigate the frame to the specified URL and return a HTTP response object.
func (*Frame) InnerHTML ¶
InnerHTML returns the innerHTML attribute of the first element found that matches the selector.
func (*Frame) InnerText ¶
InnerText returns the inner text of the first element found that matches the selector.
func (*Frame) InputValue ¶
InputValue returns the input value of the first element found that matches the selector.
func (*Frame) IsChecked ¶
IsChecked returns true if the first element that matches the selector is checked. Otherwise, returns false.
func (*Frame) IsDetached ¶
IsDetached returns whether the frame is detached or not.
func (*Frame) IsDisabled ¶
IsDisabled returns true if the first element that matches the selector is disabled. Otherwise, returns false.
func (*Frame) IsEditable ¶
IsEditable returns true if the first element that matches the selector is editable. Otherwise, returns false.
func (*Frame) IsEnabled ¶
IsEnabled returns true if the first element that matches the selector is enabled. Otherwise, returns false.
func (*Frame) IsHidden ¶
IsHidden returns true if the first element that matches the selector is hidden. Otherwise, returns false.
func (*Frame) IsVisible ¶
IsVisible returns true if the first element that matches the selector is visible. Otherwise, returns false.
func (*Frame) ParentFrame ¶
ParentFrame returns the parent frame, if one exists.
func (*Frame) Press ¶
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) SelectOption ¶
SelectOption selects the given options and returns the array of option values of the first element found that matches the selector.
func (*Frame) SetContent ¶
SetContent replaces the entire HTML document content.
func (*Frame) SetInputFiles ¶
func (*Frame) TextContent ¶
TextContent returns the textContent attribute of the first element found that matches the selector.
func (*Frame) WaitForFunction ¶
WaitForFunction waits for the given predicate to return a truthy value.
func (*Frame) WaitForLoadState ¶
WaitForLoadState waits for the given load state to be reached.
func (*Frame) WaitForNavigation ¶
WaitForNavigation waits for the given navigation lifecycle event to happen.
func (*Frame) WaitForSelector ¶
WaitForSelector waits for the given selector to match the waiting criteria.
func (*Frame) WaitForTimeout ¶
WaitForTimeout waits the specified amount of milliseconds.
type FrameBaseOptions ¶
func NewFrameBaseOptions ¶
func NewFrameBaseOptions(defaultTimeout time.Duration) *FrameBaseOptions
type FrameCheckOptions ¶
type FrameCheckOptions struct { ElementHandleBasePointerOptions Strict bool `json:"strict"` }
func NewFrameCheckOptions ¶
func NewFrameCheckOptions(defaultTimeout time.Duration) *FrameCheckOptions
type FrameClickOptions ¶
type FrameClickOptions struct { ElementHandleClickOptions Strict bool `json:"strict"` }
func NewFrameClickOptions ¶
func NewFrameClickOptions(defaultTimeout time.Duration) *FrameClickOptions
type FrameDblclickOptions ¶
type FrameDblclickOptions struct { ElementHandleDblclickOptions Strict bool `json:"strict"` }
func NewFrameDblClickOptions ¶
func NewFrameDblClickOptions(defaultTimeout time.Duration) *FrameDblclickOptions
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
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
type FrameHoverOptions ¶
type FrameHoverOptions struct { ElementHandleHoverOptions Strict bool `json:"strict"` }
func NewFrameHoverOptions ¶
func NewFrameHoverOptions(defaultTimeout time.Duration) *FrameHoverOptions
type FrameInnerHTMLOptions ¶
type FrameInnerHTMLOptions struct {
FrameBaseOptions
}
func NewFrameInnerHTMLOptions ¶
func NewFrameInnerHTMLOptions(defaultTimeout time.Duration) *FrameInnerHTMLOptions
type FrameInnerTextOptions ¶
type FrameInnerTextOptions struct {
FrameBaseOptions
}
func NewFrameInnerTextOptions ¶
func NewFrameInnerTextOptions(defaultTimeout time.Duration) *FrameInnerTextOptions
type FrameInputValueOptions ¶
type FrameInputValueOptions struct {
FrameBaseOptions
}
func NewFrameInputValueOptions ¶
func NewFrameInputValueOptions(defaultTimeout time.Duration) *FrameInputValueOptions
type FrameIsCheckedOptions ¶
type FrameIsCheckedOptions struct {
FrameBaseOptions
}
func NewFrameIsCheckedOptions ¶
func NewFrameIsCheckedOptions(defaultTimeout time.Duration) *FrameIsCheckedOptions
type FrameIsDisabledOptions ¶
type FrameIsDisabledOptions struct {
FrameBaseOptions
}
func NewFrameIsDisabledOptions ¶
func NewFrameIsDisabledOptions(defaultTimeout time.Duration) *FrameIsDisabledOptions
type FrameIsEditableOptions ¶
type FrameIsEditableOptions struct {
FrameBaseOptions
}
func NewFrameIsEditableOptions ¶
func NewFrameIsEditableOptions(defaultTimeout time.Duration) *FrameIsEditableOptions
type FrameIsEnabledOptions ¶
type FrameIsEnabledOptions struct {
FrameBaseOptions
}
func NewFrameIsEnabledOptions ¶
func NewFrameIsEnabledOptions(defaultTimeout time.Duration) *FrameIsEnabledOptions
type FrameIsHiddenOptions ¶
type FrameIsHiddenOptions struct {
FrameBaseOptions
}
func NewFrameIsHiddenOptions ¶
func NewFrameIsHiddenOptions(defaultTimeout time.Duration) *FrameIsHiddenOptions
type FrameIsVisibleOptions ¶
type FrameIsVisibleOptions struct {
FrameBaseOptions
}
func NewFrameIsVisibleOptions ¶
func NewFrameIsVisibleOptions(defaultTimeout time.Duration) *FrameIsVisibleOptions
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 ¶
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
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
type FrameTapOptions ¶
type FrameTapOptions struct { ElementHandleBasePointerOptions Modifiers []string `json:"modifiers"` Strict bool `json:"strict"` }
func NewFrameTapOptions ¶
func NewFrameTapOptions(defaultTimeout time.Duration) *FrameTapOptions
type FrameTextContentOptions ¶
type FrameTextContentOptions struct {
FrameBaseOptions
}
func NewFrameTextContentOptions ¶
func NewFrameTextContentOptions(defaultTimeout time.Duration) *FrameTextContentOptions
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
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
type FrameWaitForLoadStateOptions ¶
func NewFrameWaitForLoadStateOptions ¶
func NewFrameWaitForLoadStateOptions(defaultTimeout time.Duration) *FrameWaitForLoadStateOptions
type FrameWaitForNavigationOptions ¶
type FrameWaitForNavigationOptions struct {}
func NewFrameWaitForNavigationOptions ¶
func NewFrameWaitForNavigationOptions(defaultTimeout time.Duration) *FrameWaitForNavigationOptions
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
type Geolocation ¶
type Geolocation struct { Latitude float64 `js:"latitude"` Longitude float64 `js:"longitude"` Accurracy float64 `js:"accurracy"` }
func NewGeolocation ¶
func NewGeolocation() *Geolocation
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 ¶
NewKeyboard returns a new keyboard with a "us" layout.
func (*Keyboard) InsertText ¶
InsertText inserts a text without dispatching key events.
func (*Keyboard) Press ¶
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.
type KeyboardOptions ¶
type KeyboardOptions struct {
Delay int64 `json:"delay"`
}
func NewKeyboardOptions ¶
func NewKeyboardOptions() *KeyboardOptions
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
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
NewLocator creates and returns a new locator.
func (*Locator) Check ¶ added in v0.4.0
Check on an element using locator's selector with strict mode on.
func (*Locator) Click ¶ added in v0.4.0
Click on an element using locator's selector with strict mode on.
func (*Locator) Dblclick ¶ added in v0.4.0
Dblclick double clicks on an element using locator's selector with strict mode on.
func (*Locator) DispatchEvent ¶ added in v0.4.0
DispatchEvent dispatches an event for the element matching the locator's selector with strict mode on.
func (*Locator) Fill ¶ added in v0.4.0
Fill out the element using locator's selector with strict mode on.
func (*Locator) Focus ¶ added in v0.4.0
Focus on the element using locator's selector with strict mode on.
func (*Locator) GetAttribute ¶ added in v0.4.0
GetAttribute of the element using locator's selector with strict mode on.
func (*Locator) Hover ¶ added in v0.4.0
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
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
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
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
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
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
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
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
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
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
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
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
Tap the element found that matches the locator's selector with strict mode on.
func (*Locator) TextContent ¶ added in v0.4.0
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
Type text on the element found that matches the locator's selector with strict mode on.
type Mouse ¶
type Mouse struct {
// contains filtered or unexported fields
}
Mouse represents a mouse input device.
func (*Mouse) Click ¶
Click will trigger a series of MouseMove, MouseDown and MouseUp events 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) ToMouseDownUpOptions ¶
func (o *MouseClickOptions) ToMouseDownUpOptions() *MouseDownUpOptions
type MouseDblClickOptions ¶
func NewMouseDblClickOptions ¶
func NewMouseDblClickOptions() *MouseDblClickOptions
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
type MouseMoveOptions ¶
type MouseMoveOptions struct {
Steps int64 `json:"steps"`
}
func NewMouseMoveOptions ¶
func NewMouseMoveOptions() *MouseMoveOptions
type NavigationEvent ¶
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 ¶
AddInitScript adds script to run in all new frames.
func (*Page) AddScriptTag ¶
func (*Page) AddStyleTag ¶
func (*Page) BringToFront ¶ added in v0.1.2
func (p *Page) BringToFront()
BringToFront activates the browser tab for this page.
func (*Page) DispatchEvent ¶
func (*Page) DragAndDrop ¶
func (*Page) EmulateMedia ¶
func (*Page) EmulateVisionDeficiency ¶
EmulateVisionDeficiency activates/deactivates emulation of a vision deficiency.
func (*Page) Evaluate ¶
Evaluate runs JS code within the execution context of the main frame of the page.
func (*Page) EvaluateHandle ¶
func (*Page) ExposeBinding ¶
func (*Page) GetAttribute ¶
func (*Page) Goto ¶
Goto will navigate the page to the specified URL and return a HTTP response object.
func (*Page) IsChecked ¶
IsChecked returns true if the first element that matches the selector is checked. Otherwise, returns false.
func (*Page) Locator ¶ added in v0.4.0
Locator creates and returns a new locator for this page (main frame).
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 (*Page) SetDefaultNavigationTimeout ¶
SetDefaultNavigationTimeout sets the default navigation timeout in milliseconds.
func (*Page) SetDefaultTimeout ¶
SetDefaultTimeout sets the default maximum timeout in milliseconds.
func (*Page) SetExtraHTTPHeaders ¶
SetExtraHTTPHeaders sets default HTTP headers for page and whole frame hierarchy.
func (*Page) SetInputFiles ¶
func (*Page) SetViewportSize ¶
SetViewportSize will update the viewport width and height.
func (*Page) ViewportSize ¶
ViewportSize will return information on the viewport width and height.
func (*Page) WaitForEvent ¶
WaitForEvent waits for the specified event to trigger.
func (*Page) WaitForFunction ¶
WaitForFunction waits for the given predicate to return a truthy value.
func (*Page) WaitForLoadState ¶
WaitForLoadState waits for the specified page life cycle event.
func (*Page) WaitForNavigation ¶
WaitForNavigation waits for the given navigation lifecycle event to happen.
func (*Page) WaitForRequest ¶
func (*Page) WaitForResponse ¶
func (*Page) WaitForSelector ¶
WaitForSelector waits for the given selector to match the waiting criteria.
func (*Page) WaitForTimeout ¶
WaitForTimeout waits the specified number of milliseconds.
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
type PageReloadOptions ¶
type PageReloadOptions struct { WaitUntil LifecycleEvent `json:"waitUntil"` Timeout time.Duration `json:"timeout"` }
func NewPageReloadOptions ¶
func NewPageReloadOptions(defaultWaitUntil LifecycleEvent, defaultTimeout time.Duration) *PageReloadOptions
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
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 ProxyOptions ¶
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 ¶
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 (*Request) HeadersArray ¶
func (r *Request) HeadersArray() []api.HTTPHeader
func (*Request) IsNavigationRequest ¶
IsNavigationRequest returns whether this was a navigation request or not.
func (*Request) PostDataBuffer ¶
func (r *Request) PostDataBuffer() goja.ArrayBuffer
PostDataBuffer returns the request post data as an ArrayBuffer.
func (*Request) PostDataJSON ¶
PostDataJSON returns the request post data as a JS object.
func (*Request) RedirectedFrom ¶
func (*Request) RedirectedTo ¶
func (*Request) ResourceType ¶
ResourceType returns the request resource type.
func (*Request) Size ¶
func (r *Request) Size() api.HTTPMessageSize
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 (*Response) Body ¶
func (r *Response) Body() goja.ArrayBuffer
Body returns the response body as a binary buffer.
func (*Response) FromPrefetchCache ¶
FromPrefetchCache returns whether this response was served from prefetch cache.
func (*Response) FromServiceWorker ¶
FromServiceWorker returns whether this response was served by a service worker.
func (*Response) HeaderValues ¶
func (*Response) HeadersArray ¶
func (r *Response) HeadersArray() []api.HTTPHeader
func (*Response) Ok ¶
Ok returns true if status code of response if considered ok, otherwise returns false.
func (*Response) SecurityDetails ¶
func (*Response) ServerAddr ¶
ServerAddr returns the remote address of the server.
func (*Response) Size ¶
func (r *Response) Size() api.HTTPMessageSize
func (*Response) StatusText ¶
StatusText returns the response status text.
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 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 ¶
type SelectorPart ¶
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 ¶
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 ¶
Viewport represents a page viewport.
type Worker ¶
type Worker struct { BaseEventEmitter // contains filtered or unexported fields }
func (*Worker) EvaluateHandle ¶
EvaluateHandle evaluates a page function in the context of the web worker and returns a JS handle.
Source Files ¶
- barrier.go
- browser.go
- browser_context.go
- browser_context_options.go
- browser_process.go
- connection.go
- consts.go
- context.go
- device.go
- element_handle.go
- element_handle_options.go
- errors.go
- event_emitter.go
- execution_context.go
- field_name_mapper.go
- frame.go
- frame_manager.go
- frame_options.go
- frame_session.go
- helpers.go
- hooks.go
- js_handle.go
- keyboard.go
- keyboard_options.go
- launch.go
- locator.go
- mouse.go
- mouse_options.go
- network_manager.go
- page.go
- page_options.go
- remote_object.go
- request.go
- response.go
- screenshotter.go
- selectors.go
- session.go
- timeout.go
- touchscreen.go
- types.go
- worker.go