Documentation
¶
Overview ¶
Package common provides the main logic of the browser module. This package will be split into multiple packages in the future.
Index ¶
- Constants
- func ConvertSelectOptionValues(rt *sobek.Runtime, values sobek.Value) ([]any, error)
- func GetDevices() map[string]Device
- func GetIterationID(ctx context.Context) string
- func GetNetworkProfiles() map[string]NetworkProfile
- func NewJSHandle(ctx context.Context, s session, ectx *ExecutionContext, f *Frame, ...) jsHandle
- func TraceAPICall(ctx context.Context, targetID string, spanName string, ...) (context.Context, trace.Span)
- func TraceEvent(ctx context.Context, targetID string, eventName string, spanID string, ...) (context.Context, trace.Span)
- func TraceNavigation(ctx context.Context, targetID string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func TrimQuotes(s string) string
- func WithBrowserOptions(ctx context.Context, opts *BrowserOptions) context.Context
- func WithHooks(ctx context.Context, hooks *Hooks) context.Context
- func WithIterationID(ctx context.Context, iterID string) context.Context
- func WithTracer(ctx context.Context, tracer Tracer) context.Context
- type Action
- type ActionFunc
- type Barrier
- type BaseEventEmitter
- type BaseJSHandle
- func (h *BaseJSHandle) AsElement() *ElementHandle
- func (h *BaseJSHandle) Dispose() error
- func (h *BaseJSHandle) Evaluate(pageFunc string, args ...any) (any, error)
- func (h *BaseJSHandle) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error)
- func (h *BaseJSHandle) GetProperties() (map[string]JSHandleAPI, error)
- func (h *BaseJSHandle) JSONValue() (string, error)
- func (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID
- type BigIntParseError
- type Browser
- func (b *Browser) Close()
- func (b *Browser) CloseContext() error
- func (b *Browser) Context() *BrowserContext
- func (b *Browser) IsConnected() bool
- func (b *Browser) NewContext(opts *BrowserContextOptions) (*BrowserContext, error)
- func (b *Browser) NewPage(opts *BrowserContextOptions) (*Page, error)
- func (b *Browser) On(event string) (bool, error)
- func (b *Browser) UserAgent() string
- func (b *Browser) Version() string
- func (b *Browser) WsURL() string
- type BrowserContext
- func (b *BrowserContext) AddCookies(cookies []*Cookie) error
- func (b *BrowserContext) AddInitScript(script string) error
- func (b *BrowserContext) Browser() *Browser
- func (b *BrowserContext) ClearCookies() error
- func (b *BrowserContext) ClearPermissions() error
- func (b *BrowserContext) Close() error
- func (b *BrowserContext) Cookies(urls ...string) ([]*Cookie, error)
- func (b *BrowserContext) GrantPermissions(permissions []string, opts GrantPermissionsOptions) error
- func (b *BrowserContext) NewPage() (*Page, error)
- func (b *BrowserContext) Pages() []*Page
- func (b *BrowserContext) SetDefaultNavigationTimeout(timeout int64)
- func (b *BrowserContext) SetDefaultTimeout(timeout int64)
- func (b *BrowserContext) SetGeolocation(g *Geolocation) error
- func (b *BrowserContext) SetHTTPCredentials(hc Credentials) errordeprecated
- func (b *BrowserContext) SetOffline(offline bool) error
- func (b *BrowserContext) Timeout() time.Duration
- func (b *BrowserContext) WaitForEvent(event string, f func(p *Page) (bool, error), timeout time.Duration) (any, error)
- type BrowserContextOptions
- type BrowserOptions
- type BrowserProcess
- type CPUProfile
- type ColorScheme
- type Connection
- type ConsoleMessage
- type Cookie
- type CookieSameSite
- type Credentials
- type DOMElementState
- type Device
- type DocumentInfo
- type ElementHandle
- func (h *ElementHandle) AsElement() *ElementHandle
- func (h *ElementHandle) BoundingBox() *Rect
- func (h *ElementHandle) Check(opts *ElementHandleSetCheckedOptions) error
- func (h *ElementHandle) Click(opts *ElementHandleClickOptions) error
- func (h *ElementHandle) ContentFrame() (*Frame, error)
- func (h *ElementHandle) Dblclick(opts *ElementHandleDblclickOptions) error
- func (h *ElementHandle) DefaultTimeout() time.Duration
- func (h *ElementHandle) DispatchEvent(typ string, eventInit any) error
- func (h *ElementHandle) Fill(value string, opts *ElementHandleBaseOptions) error
- func (h *ElementHandle) Focus() error
- func (h *ElementHandle) GetAttribute(name string) (string, bool, error)
- func (h *ElementHandle) Hover(opts *ElementHandleHoverOptions) error
- func (h *ElementHandle) InnerHTML() (string, error)
- func (h *ElementHandle) InnerText() (string, error)
- func (h *ElementHandle) InputValue(opts *ElementHandleBaseOptions) (string, error)
- func (h *ElementHandle) IsChecked() (bool, error)
- func (h *ElementHandle) IsDisabled() (bool, error)
- func (h *ElementHandle) IsEditable() (bool, error)
- func (h *ElementHandle) IsEnabled() (bool, error)
- func (h *ElementHandle) IsHidden() (bool, error)
- func (h *ElementHandle) IsVisible() (bool, error)
- func (h *ElementHandle) OwnerFrame() (_ *Frame, rerr error)
- func (h *ElementHandle) Press(key string, opts *ElementHandlePressOptions) error
- func (h *ElementHandle) Query(selector string, strict bool) (_ *ElementHandle, rerr error)
- func (h *ElementHandle) QueryAll(selector string) ([]*ElementHandle, error)
- func (h *ElementHandle) Screenshot(opts *ElementHandleScreenshotOptions, sp ScreenshotPersister) ([]byte, error)
- func (h *ElementHandle) ScrollIntoViewIfNeeded(opts *ElementHandleBaseOptions) error
- func (h *ElementHandle) SelectOption(values []any, opts *ElementHandleBaseOptions) ([]string, error)
- func (h *ElementHandle) SelectText(opts *ElementHandleBaseOptions) error
- func (h *ElementHandle) SetChecked(checked bool, opts *ElementHandleSetCheckedOptions) error
- func (h *ElementHandle) SetInputFiles(files *Files, opts *ElementHandleSetInputFilesOptions) error
- func (h *ElementHandle) Tap(opts *ElementHandleTapOptions) error
- func (h *ElementHandle) TextContent() (string, bool, error)
- func (h *ElementHandle) Timeout() time.Duration
- func (h *ElementHandle) Type(text string, opts *ElementHandleTypeOptions) error
- func (h *ElementHandle) Uncheck(opts *ElementHandleSetCheckedOptions) error
- func (h *ElementHandle) WaitForElementState(state string, opts *ElementHandleWaitForElementStateOptions) error
- func (h *ElementHandle) WaitForSelector(selector string, opts *FrameWaitForSelectorOptions) (*ElementHandle, error)
- type ElementHandleBaseOptions
- type ElementHandleBasePointerOptions
- type ElementHandleCheckOptions
- type ElementHandleClickOptions
- type ElementHandleDblclickOptions
- type ElementHandleDispatchEventOptions
- type ElementHandleHoverOptions
- type ElementHandlePressOptions
- type ElementHandleScreenshotOptions
- type ElementHandleSetCheckedOptions
- type ElementHandleSetInputFilesOptions
- type ElementHandleTapOptions
- type ElementHandleTypeOptions
- type ElementHandleWaitForElementStateOptions
- type EmulatedSize
- type Error
- type Event
- type EventEmitter
- type ExecutionContext
- func (e *ExecutionContext) Eval(apiCtx context.Context, js string, args ...any) (any, error)
- func (e *ExecutionContext) EvalHandle(apiCtx context.Context, js string, args ...any) (JSHandleAPI, error)
- func (e *ExecutionContext) Frame() *Frame
- func (e *ExecutionContext) ID() runtime.ExecutionContextID
- type File
- type Files
- type Frame
- func (f *Frame) Check(selector string, popts *FrameCheckOptions) error
- func (f *Frame) ChildFrames() []*Frame
- func (f *Frame) Click(selector string, opts *FrameClickOptions) error
- func (f *Frame) Content() (string, error)
- func (f *Frame) Dblclick(selector string, popts *FrameDblclickOptions) error
- func (f *Frame) DispatchEvent(selector, typ string, eventInit any, opts *FrameDispatchEventOptions) error
- func (f *Frame) Evaluate(pageFunc string, args ...any) (any, error)
- func (f *Frame) EvaluateGlobal(ctx context.Context, js string) error
- func (f *Frame) EvaluateHandle(pageFunc string, args ...any) (handle JSHandleAPI, _ error)
- func (f *Frame) EvaluateWithContext(ctx context.Context, pageFunc string, args ...any) (any, error)
- func (f *Frame) Fill(selector, value string, popts *FrameFillOptions) error
- func (f *Frame) Focus(selector string, popts *FrameBaseOptions) error
- func (f *Frame) FrameElement() (*ElementHandle, error)
- func (f *Frame) GetAttribute(selector, name string, popts *FrameBaseOptions) (string, bool, error)
- func (f *Frame) Goto(url string, opts *FrameGotoOptions) (*Response, error)
- func (f *Frame) Hover(selector string, popts *FrameHoverOptions) error
- func (f *Frame) ID() string
- func (f *Frame) InnerHTML(selector string, popts *FrameInnerHTMLOptions) (string, error)
- func (f *Frame) InnerText(selector string, popts *FrameInnerTextOptions) (string, error)
- func (f *Frame) InputValue(selector string, popts *FrameInputValueOptions) (string, error)
- func (f *Frame) IsChecked(selector string, opts *FrameIsCheckedOptions) (bool, error)
- func (f *Frame) IsDetached() bool
- func (f *Frame) IsDisabled(selector string, opts *FrameIsDisabledOptions) (bool, error)
- func (f *Frame) IsEditable(selector string, opts *FrameIsEditableOptions) (bool, error)
- func (f *Frame) IsEnabled(selector string, opts *FrameIsEnabledOptions) (bool, error)
- func (f *Frame) IsHidden(selector string, opts *FrameIsHiddenOptions) (bool, error)
- func (f *Frame) IsVisible(selector string, opts *FrameIsVisibleOptions) (bool, error)
- func (f *Frame) LoaderID() string
- func (f *Frame) Locator(selector string, opts sobek.Value) *Locator
- func (f *Frame) Name() string
- func (f *Frame) NavigationTimeout() time.Duration
- func (f *Frame) Page() *Page
- func (f *Frame) ParentFrame() *Frame
- func (f *Frame) Press(selector, key string, opts *FramePressOptions) error
- func (f *Frame) Query(selector string, strict bool) (*ElementHandle, error)
- func (f *Frame) QueryAll(selector string) ([]*ElementHandle, error)
- func (f *Frame) Referrer() string
- func (f *Frame) SelectOption(selector string, values []any, popts *FrameSelectOptionOptions) ([]string, error)
- func (f *Frame) SetChecked(selector string, checked bool, popts *FrameCheckOptions) error
- func (f *Frame) SetContent(html string, _ *FrameSetContentOptions) error
- func (f *Frame) SetInputFiles(selector string, pfiles *Files, popts *FrameSetInputFilesOptions) error
- func (f *Frame) Tap(selector string, opts *FrameTapOptions) error
- func (f *Frame) TextContent(selector string, popts *FrameTextContentOptions) (string, bool, error)
- func (f *Frame) Timeout() time.Duration
- func (f *Frame) Title() (string, error)
- func (f *Frame) Type(selector, text string, popts *FrameTypeOptions) error
- func (f *Frame) URL() string
- func (f *Frame) Uncheck(selector string, popts *FrameUncheckOptions) error
- func (f *Frame) WaitForFunction(js string, opts *FrameWaitForFunctionOptions, jsArgs ...any) (any, error)
- func (f *Frame) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error
- func (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions) (*Response, error)
- func (f *Frame) WaitForSelector(selector string, popts *FrameWaitForSelectorOptions) (*ElementHandle, error)
- 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 FrameLifecycleEvent
- type FrameManager
- func (m *FrameManager) Frames() []*Frame
- func (m *FrameManager) ID() int64
- func (m *FrameManager) MainFrame() *Frame
- func (m *FrameManager) MainFrameURL() string
- func (m *FrameManager) NavigateFrame(frame *Frame, url string, parsedOpts *FrameGotoOptions) (*Response, error)
- func (m *FrameManager) Page() *Page
- type FramePressOptions
- type FrameSelectOptionOptions
- type FrameSession
- type FrameSetContentOptions
- type FrameSetInputFilesOptions
- type FrameTapOptions
- type FrameTextContentOptions
- type FrameTypeOptions
- type FrameUncheckOptions
- type FrameWaitForFunctionOptions
- type FrameWaitForLoadStateOptions
- type FrameWaitForNavigationOptions
- type FrameWaitForSelectorOptions
- type Geolocation
- type GrantPermissionsOptions
- type HTTPHeader
- type HTTPMessageSize
- type Hook
- type HookID
- type Hooks
- type ImageFormat
- type JSHandleAPI
- type K6BrowserCheckRegEx
- type Keyboard
- type KeyboardOptions
- type LifecycleEvent
- type Locator
- func (l *Locator) Check(opts sobek.Value) error
- func (l *Locator) Clear(opts *FrameFillOptions) error
- func (l *Locator) Click(opts *FrameClickOptions) error
- func (l *Locator) Dblclick(opts sobek.Value) error
- func (l *Locator) DefaultTimeout() time.Duration
- func (l *Locator) DispatchEvent(typ string, eventInit any, opts *FrameDispatchEventOptions) error
- func (l *Locator) Fill(value string, opts sobek.Value) error
- func (l *Locator) Focus(opts sobek.Value) error
- func (l *Locator) GetAttribute(name string, opts sobek.Value) (string, bool, error)
- func (l *Locator) Hover(opts sobek.Value) error
- func (l *Locator) InnerHTML(opts sobek.Value) (string, error)
- func (l *Locator) InnerText(opts sobek.Value) (string, error)
- func (l *Locator) InputValue(opts sobek.Value) (string, error)
- func (l *Locator) IsChecked(opts sobek.Value) (bool, error)
- func (l *Locator) IsDisabled(opts sobek.Value) (bool, error)
- func (l *Locator) IsEditable(opts sobek.Value) (bool, error)
- func (l *Locator) IsEnabled(opts sobek.Value) (bool, error)
- func (l *Locator) IsHidden() (bool, error)
- func (l *Locator) IsVisible() (bool, error)
- func (l *Locator) Press(key string, opts sobek.Value) error
- func (l *Locator) SelectOption(values sobek.Value, opts sobek.Value) ([]string, error)
- func (l *Locator) SetChecked(checked bool, opts sobek.Value) error
- func (l *Locator) Tap(opts *FrameTapOptions) error
- func (l *Locator) TextContent(opts sobek.Value) (string, bool, error)
- func (l *Locator) Timeout() time.Duration
- func (l *Locator) Type(text string, opts sobek.Value) error
- func (l *Locator) Uncheck(opts sobek.Value) error
- func (l *Locator) WaitFor(opts sobek.Value) error
- type Match
- type MediaType
- type MetricEvent
- type Mouse
- func (m *Mouse) Click(x float64, y float64, opts *MouseClickOptions) error
- func (m *Mouse) DblClick(x float64, y float64, opts *MouseDblClickOptions) error
- func (m *Mouse) Down(opts *MouseDownUpOptions) error
- func (m *Mouse) Move(x float64, y float64, opts *MouseMoveOptions) error
- func (m *Mouse) Up(opts *MouseDownUpOptions) error
- type MouseClickOptions
- type MouseDblClickOptions
- type MouseDownUpOptions
- type MouseMoveOptions
- type NavigationEvent
- type NetworkManager
- func (m *NetworkManager) Authenticate(credentials Credentials) error
- func (m *NetworkManager) SetCacheEnabled(enabled bool)
- func (m *NetworkManager) SetExtraHTTPHeaders(headers network.Headers) error
- func (m *NetworkManager) SetOfflineMode(offline bool) error
- func (m *NetworkManager) SetUserAgent(userAgent string)
- func (m *NetworkManager) ThrottleNetwork(networkProfile NetworkProfile) error
- type NetworkProfile
- type NewRequestParams
- type Page
- func (p *Page) BringToFront() error
- func (p *Page) Check(selector string, popts *FrameCheckOptions) error
- func (p *Page) Click(selector string, opts *FrameClickOptions) error
- func (p *Page) Close() error
- func (p *Page) Content() (string, error)
- func (p *Page) Context() *BrowserContext
- func (p *Page) Dblclick(selector string, popts *FrameDblclickOptions) error
- func (p *Page) DispatchEvent(selector string, typ string, eventInit any, opts *FrameDispatchEventOptions) error
- func (p *Page) EmulateMedia(popts *PageEmulateMediaOptions) error
- func (p *Page) EmulateVisionDeficiency(typ string) error
- func (p *Page) Evaluate(pageFunc string, args ...any) (any, error)
- func (p *Page) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error)
- func (p *Page) Fill(selector string, value string, popts *FrameFillOptions) error
- func (p *Page) Focus(selector string, popts *FrameBaseOptions) error
- func (p *Page) Frames() []*Frame
- func (p *Page) GetAttribute(selector string, name string, popts *FrameBaseOptions) (string, bool, error)
- func (p *Page) GetKeyboard() *Keyboard
- func (p *Page) GetMouse() *Mouse
- func (p *Page) GetTouchscreen() *Touchscreen
- func (p *Page) Goto(url string, opts *FrameGotoOptions) (*Response, error)
- func (p *Page) Hover(selector string, popts *FrameHoverOptions) error
- func (p *Page) InnerHTML(selector string, popts *FrameInnerHTMLOptions) (string, error)
- func (p *Page) InnerText(selector string, popts *FrameInnerTextOptions) (string, error)
- func (p *Page) InputValue(selector string, popts *FrameInputValueOptions) (string, error)
- func (p *Page) IsChecked(selector string, opts *FrameIsCheckedOptions) (bool, error)
- func (p *Page) IsClosed() bool
- func (p *Page) IsDisabled(selector string, opts *FrameIsDisabledOptions) (bool, error)
- func (p *Page) IsEditable(selector string, opts *FrameIsEditableOptions) (bool, error)
- func (p *Page) IsEnabled(selector string, opts *FrameIsEnabledOptions) (bool, error)
- func (p *Page) IsHidden(selector string, opts *FrameIsHiddenOptions) (bool, error)
- func (p *Page) IsVisible(selector string, opts *FrameIsVisibleOptions) (bool, error)
- func (p *Page) Locator(selector string, opts sobek.Value) *Locator
- func (p *Page) MainFrame() *Frame
- func (p *Page) NavigationTimeout() time.Duration
- func (p *Page) On(event PageOnEventName, handler PageOnHandler) error
- func (p *Page) Opener() *Page
- func (p *Page) Press(selector string, key string, opts *FramePressOptions) error
- func (p *Page) Query(selector string) (*ElementHandle, error)
- func (p *Page) QueryAll(selector string) ([]*ElementHandle, error)
- func (p *Page) Referrer() string
- func (p *Page) Reload(opts *PageReloadOptions) (*Response, error)
- func (p *Page) Screenshot(opts *PageScreenshotOptions, sp ScreenshotPersister) ([]byte, error)
- func (p *Page) SelectOption(selector string, values []any, popts *FrameSelectOptionOptions) ([]string, error)
- func (p *Page) SetChecked(selector string, checked bool, popts *FrameCheckOptions) error
- func (p *Page) SetContent(html string, opts *FrameSetContentOptions) error
- func (p *Page) SetDefaultNavigationTimeout(timeout int64)
- func (p *Page) SetDefaultTimeout(timeout int64)
- func (p *Page) SetExtraHTTPHeaders(headers map[string]string) error
- func (p *Page) SetInputFiles(selector string, files *Files, opts *FrameSetInputFilesOptions) error
- func (p *Page) SetViewportSize(viewportSize *Size) error
- func (p *Page) Tap(selector string, opts *FrameTapOptions) error
- func (p *Page) TargetID() string
- func (p *Page) TextContent(selector string, popts *FrameTextContentOptions) (string, bool, error)
- func (p *Page) ThrottleCPU(cpuProfile CPUProfile) error
- func (p *Page) ThrottleNetwork(networkProfile NetworkProfile) error
- func (p *Page) Timeout() time.Duration
- func (p *Page) Title() (string, error)
- func (p *Page) Type(selector string, text string, popts *FrameTypeOptions) error
- func (p *Page) URL() (string, error)
- func (p *Page) Uncheck(selector string, popts *FrameUncheckOptions) error
- func (p *Page) ViewportSize() map[string]float64
- func (p *Page) WaitForFunction(js string, opts *FrameWaitForFunctionOptions, jsArgs ...any) (any, error)
- func (p *Page) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error
- func (p *Page) WaitForNavigation(opts *FrameWaitForNavigationOptions) (*Response, error)
- func (p *Page) WaitForSelector(selector string, popts *FrameWaitForSelectorOptions) (*ElementHandle, error)
- func (p *Page) WaitForTimeout(timeout int64)
- func (p *Page) Workers() []*Worker
- type PageEmulateMediaOptions
- type PageOnEvent
- type PageOnEventName
- type PageOnHandler
- type PageReloadOptions
- type PageScreenshotOptions
- type PollingType
- type Position
- type Rect
- type ReducedMotion
- type RemoteAddress
- type Request
- func (r *Request) AllHeaders() map[string]string
- func (r *Request) Frame() *Frame
- func (r *Request) HeaderValue(name string) (string, bool)
- func (r *Request) Headers() map[string]string
- func (r *Request) HeadersArray() []HTTPHeader
- func (r *Request) IsNavigationRequest() bool
- func (r *Request) Method() string
- func (r *Request) PostData() string
- func (r *Request) PostDataBuffer() []byte
- func (r *Request) ResourceType() string
- func (r *Request) Response() *Response
- func (r *Request) Size() HTTPMessageSize
- func (r *Request) Timing() *resourceTiming
- func (r *Request) URL() string
- type Response
- func (r *Response) AllHeaders() map[string]string
- func (r *Response) Body() ([]byte, error)
- func (r *Response) Frame() *Frame
- func (r *Response) FromCache() bool
- func (r *Response) FromPrefetchCache() bool
- func (r *Response) FromServiceWorker() bool
- func (r *Response) HeaderValue(name string) (string, bool)
- func (r *Response) HeaderValues(name string) []string
- func (r *Response) Headers() map[string]string
- func (r *Response) HeadersArray() []HTTPHeader
- func (r *Response) JSON() (any, error)
- func (r *Response) Ok() bool
- func (r *Response) Request() *Request
- func (r *Response) SecurityDetails() *SecurityDetails
- func (r *Response) ServerAddr() *RemoteAddress
- func (r *Response) Size() HTTPMessageSize
- func (r *Response) Status() int64
- func (r *Response) StatusText() string
- func (r *Response) Text() (string, error)
- func (r *Response) URL() string
- type Screen
- type ScreenshotPersister
- type ScrollIntoViewOptions
- type ScrollPosition
- type SecurityDetails
- type SelectOption
- type Selector
- type SelectorPart
- type Session
- func (s *Session) Closed() bool
- 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 TagMatches
- type TimeoutSettings
- type Touchscreen
- type Tracer
- type UnserializableValueError
- type Viewport
- type Worker
Constants ¶
const ( BrowserStateOpen int64 = iota BrowserStateClosed )
const ( DefaultLocale string = "en-US" DefaultScreenWidth int64 = 1280 DefaultScreenHeight int64 = 720 DefaultTimeout time.Duration = 30 * time.Second LifeCycleNetworkIdleTimeout time.Duration = 500 * time.Millisecond StrictModeOff = false )
const ( EventBrowserDisconnected string = "disconnected" EventBrowserContextPage string = "page" EventConnectionClose string = "close" EventFrameAddLifecycle string = "addlifecycle" )
const ( ResourceTypeDocument string = "Document" ResourceTypeStylesheet string = "Stylesheet" ResourceTypeImage string = "Image" ResourceTypeMedia string = "Media" ResourceTypeFont string = "Font" ResourceTypeScript string = "Script" ResourceTypeTextTrack string = "TextTrack" ResourceTypeXHR string = "XHR" ResourceTypeFetch string = "Fetch" ResourceTypePrefetch string = "Prefetch" ResourceTypeEventSource string = "EventSource" ResourceTypeWebSocket string = "WebSocket" ResourceTypeManifest string = "Manifest" ResourceTypeSignedExchange string = "SignedExchange" ResourceTypePing string = "Ping" ResourceTypeCSPViolationReport string = "CSPViolationReport" ResourceTypePreflight string = "Preflight" ResourceTypeOther string = "Other" ResourceTypeUnknown string = "Unknown" )
These ResourceTypes are duplicates of CDP's network.ResourceType. We want to work with our version of ResourceType to catch any breaking changes early.
const ( ModifierKeyAlt int64 = 1 << iota ModifierKeyControl ModifierKeyMeta ModifierKeyShift )
const BlankPage = "about:blank"
BlankPage represents a blank page.
Variables ¶
This section is empty.
Functions ¶
func GetDevices ¶
GetDevices returns predefined emulation settings for many end-user devices.
func GetIterationID ¶
GetIterationID returns the iteration identifier attached to the context.
func GetNetworkProfiles ¶
func GetNetworkProfiles() map[string]NetworkProfile
GetNetworkProfiles returns NetworkProfiles which are ready to be used to throttle the network with page.throttleNetwork.
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 TraceAPICall ¶
func TraceAPICall( ctx context.Context, targetID string, spanName string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span)
TraceAPICall is a helper method that retrieves the Tracer from the given ctx and calls its TraceAPICall implementation. If the Tracer is not present in the given ctx, it returns a noopSpan and the given context.
func TraceEvent ¶
func TraceEvent( ctx context.Context, targetID string, eventName string, spanID string, options ...trace.SpanStartOption, ) (context.Context, trace.Span)
TraceEvent is a helper method that retrieves the Tracer from the given ctx and calls its TraceEvent implementation. If the Tracer is not present in the given ctx, it returns a noopSpan and the given context.
func TraceNavigation ¶
func TraceNavigation( ctx context.Context, targetID string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span)
TraceNavigation is a helper method that retrieves the Tracer from the given ctx and calls its TraceNavigation implementation. If the Tracer is not present in the given ctx, it returns a noopSpan and the given context.
func TrimQuotes ¶
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 WithBrowserOptions ¶
func WithBrowserOptions(ctx context.Context, opts *BrowserOptions) context.Context
WithBrowserOptions adds the browser options to the context.
func WithIterationID ¶
WithIterationID adds an identifier for the current iteration to the 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() *ElementHandle
AsElement returns an element handle if this JSHandle is a reference to a JS HTML element.
func (*BaseJSHandle) Dispose ¶
func (h *BaseJSHandle) Dispose() error
Dispose releases the remote object.
func (*BaseJSHandle) Evaluate ¶
func (h *BaseJSHandle) Evaluate(pageFunc string, args ...any) (any, error)
Evaluate will evaluate provided page function within an execution context.
func (*BaseJSHandle) EvaluateHandle ¶
func (h *BaseJSHandle) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error)
EvaluateHandle will evaluate provided page function within an execution context.
func (*BaseJSHandle) GetProperties ¶
func (h *BaseJSHandle) GetProperties() (map[string]JSHandleAPI, error)
GetProperties retreives the JS handle's properties.
func (*BaseJSHandle) JSONValue ¶
func (h *BaseJSHandle) JSONValue() (string, error)
JSONValue returns a JSON version of this JS handle.
func (*BaseJSHandle) ObjectID ¶
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 {
// contains filtered or unexported fields
}
Browser stores a Browser context.
func NewBrowser ¶
func NewBrowser( ctx context.Context, vuCtx context.Context, vuCtxCancelFn context.CancelFunc, browserProc *BrowserProcess, browserOpts *BrowserOptions, logger *log.Logger, ) (*Browser, error)
NewBrowser creates a new browser, connects to it, then returns it.
func (*Browser) CloseContext ¶
CloseContext is a short-cut function to close the current browser's context. If there is no active browser context, it returns an error.
func (*Browser) Context ¶
func (b *Browser) Context() *BrowserContext
Context returns the current browser context or nil.
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 *BrowserContextOptions) (*BrowserContext, error)
NewContext creates a new incognito-like browser context.
func (*Browser) NewPage ¶
func (b *Browser) NewPage(opts *BrowserContextOptions) (*Page, error)
NewPage creates a new tab in the browser window.
func (*Browser) On ¶
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 // DownloadsPath is the path where downloads will be stored. DownloadsPath string // 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, error)
NewBrowserContext creates a new browser context.
func (*BrowserContext) AddCookies ¶
func (b *BrowserContext) AddCookies(cookies []*Cookie) error
AddCookies adds cookies into this browser context. All pages within this context will have these cookies installed.
func (*BrowserContext) AddInitScript ¶
func (b *BrowserContext) AddInitScript(script string) error
AddInitScript adds a script that will be initialized on all new pages.
func (*BrowserContext) Browser ¶
func (b *BrowserContext) Browser() *Browser
Browser returns the browser instance that this browser context belongs to.
func (*BrowserContext) ClearCookies ¶
func (b *BrowserContext) ClearCookies() error
ClearCookies clears cookies.
func (*BrowserContext) ClearPermissions ¶
func (b *BrowserContext) ClearPermissions() error
ClearPermissions clears any permission overrides.
func (*BrowserContext) Close ¶
func (b *BrowserContext) Close() error
Close shuts down the browser context.
func (*BrowserContext) Cookies ¶
func (b *BrowserContext) Cookies(urls ...string) ([]*Cookie, error)
Cookies returns all cookies. Some of them can be added with the AddCookies method and some of them are automatically taken from the browser context when it is created. And some of them are set by the page, i.e., using the Set-Cookie HTTP header or via JavaScript like document.cookie.
func (*BrowserContext) GrantPermissions ¶
func (b *BrowserContext) GrantPermissions(permissions []string, opts GrantPermissionsOptions) error
GrantPermissions enables the specified permissions, all others will be disabled.
func (*BrowserContext) NewPage ¶
func (b *BrowserContext) NewPage() (*Page, error)
NewPage creates a new page inside this browser context.
func (*BrowserContext) Pages ¶
func (b *BrowserContext) Pages() []*Page
Pages returns a list of pages inside this browser context.
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) SetGeolocation ¶
func (b *BrowserContext) SetGeolocation(g *Geolocation) error
SetGeolocation overrides the geo location of the user.
func (*BrowserContext) SetHTTPCredentials
deprecated
func (b *BrowserContext) SetHTTPCredentials(hc Credentials) error
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) error
SetOffline toggles the browser's connectivity on/off.
func (*BrowserContext) Timeout ¶
func (b *BrowserContext) Timeout() time.Duration
Timeout will return the default timeout or the one set by the user.
type BrowserContextOptions ¶
type BrowserContextOptions struct { AcceptDownloads bool `js:"acceptDownloads"` DownloadsPath string `js:"downloadsPath"` 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 DefaultBrowserContextOptions ¶
func DefaultBrowserContextOptions() *BrowserContextOptions
DefaultBrowserContextOptions returns the default browser context options.
type BrowserOptions ¶
type BrowserOptions struct { Args []string Debug bool ExecutablePath string Headless bool IgnoreDefaultArgs []string LogCategoryFilter string // TODO: Do not expose slowMo option by now. // See https://go.k6.io/k6/js/modules/k6/browser/issues/857. SlowMo time.Duration Timeout time.Duration // contains filtered or unexported fields }
BrowserOptions stores browser options.
func GetBrowserOptions ¶
func GetBrowserOptions(ctx context.Context) *BrowserOptions
GetBrowserOptions returns the browser options attached to the context.
func NewLocalBrowserOptions ¶
func NewLocalBrowserOptions() *BrowserOptions
NewLocalBrowserOptions returns a new BrowserOptions for a browser launched in the local machine.
func NewRemoteBrowserOptions ¶
func NewRemoteBrowserOptions() *BrowserOptions
NewRemoteBrowserOptions returns a new BrowserOptions for a browser running in a remote machine.
type BrowserProcess ¶
type BrowserProcess struct {
// contains filtered or unexported fields
}
func NewLocalBrowserProcess ¶
func NewLocalBrowserProcess( ctx context.Context, path string, args []string, dataDir *storage.Dir, ctxCancel context.CancelFunc, logger *log.Logger, ) (*BrowserProcess, error)
NewLocalBrowserProcess starts a local browser process and returns a new BrowserProcess instance to interact with it.
func NewRemoteBrowserProcess ¶
func NewRemoteBrowserProcess( ctx context.Context, wsURL string, ctxCancel context.CancelFunc, logger *log.Logger, ) (*BrowserProcess, error)
NewRemoteBrowserProcess returns a new BrowserProcess instance which references a remote browser process.
func (*BrowserProcess) Cleanup ¶
func (p *BrowserProcess) Cleanup() error
Cleanup cleans up the metadata associated with the browser process, mainly the browser data directory.
func (*BrowserProcess) GracefulClose ¶
func (p *BrowserProcess) GracefulClose()
GracefulClose triggers a graceful closing of the browser process.
func (*BrowserProcess) Pid ¶
func (p *BrowserProcess) Pid() int
Pid returns the browser process ID, or -1 if this is unknown.
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 CPUProfile ¶
type CPUProfile struct { // rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). Rate float64 }
CPUProfile is used in throttleCPU.
type ColorScheme ¶
type ColorScheme string
ColorScheme represents a browser color scheme.
const ( ColorSchemeLight ColorScheme = "light" ColorSchemeDark ColorScheme = "dark" ColorSchemeNoPreference ColorScheme = "no-preference" )
Valid color schemes.
func (ColorScheme) MarshalJSON ¶
func (c ColorScheme) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted JSON string.
func (ColorScheme) String ¶
func (c ColorScheme) String() string
func (*ColorScheme) UnmarshalJSON ¶
func (c *ColorScheme) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a quoted JSON string to the enum value.
type Connection ¶
type Connection struct { BaseEventEmitter // contains filtered or unexported fields }
Connection represents a WebSocket connection and the root "Browser Session".
┌───────────────────────────────────────────────────────────────────┐ │ │ │ Browser Process │ │ │ └───────────────────────────────────────────────────────────────────┘ ┌───────────────────────────┐ │ ▲ │Reads JSON-RPC CDP messages│ │ │ │from WS connection and puts│ ▼ │ │ them on incoming queue of │ ┌───────────────────────────────────────────────────────────────────┐ │ target session, as ├─────────────■ │ │ identified by message │ │ WebSocket Connection │ │ session ID. Messages │ │ │ │ without a session ID are │ └───────────────────────────────────────────────────────────────────┘ │considered to belong to the│ │ ▲ │ ▲ │ root "Browser Session". │ │ │ │ │ └───────────────────────────┘ ▼ │ ▼ │ ┌───────────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │ Handles CDP messages on ├─────────────■ │ │ │ │incoming queue and puts CDP│ │ Session │ * * * * * │ Session │ │ messages on outgoing │ │ │ │ │ │ channel of WS connection. │ └────────────────────┘ └────────────────────┘ └───────────────────────────┘ │ ▲ │ ▲ │ │ │ │ │ │ ▼ │ ▼ │ ▼ │ ┌───────────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │Registers with session as a├─────────────■ │ │ │ │handler for a specific CDP │ │ Event Listener │ * * * * * │ Event Listener │ │ Domain event. │ │ │ │ │ └───────────────────────────┘ └────────────────────┘ └────────────────────┘
func NewConnection ¶
func NewConnection( ctx context.Context, wsURL string, logger *log.Logger, onTargetAttachedToTarget func(*target.EventAttachedToTarget) bool, ) (*Connection, error)
NewConnection creates a new browser.
func (*Connection) Close ¶
func (c *Connection) Close()
Close cleanly closes the WebSocket connection. It returns an error if sending the Close control frame fails.
Optional code to override default websocket.CloseGoingAway (1001).
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.
func (*Connection) IgnoreIOErrors ¶
func (c *Connection) IgnoreIOErrors()
IgnoreIOErrors signals that the connection will soon be closed, so that any received IO errors can be disregarded.
type ConsoleMessage ¶
type ConsoleMessage struct { // Args represent the list of arguments passed to a console function call. Args []JSHandleAPI // Page is the page that produced the console message, if any. Page *Page // Text represents the text of the console message. Text string // Type is the type of the console message. // It can be one of 'log', 'debug', 'info', 'error', 'warning', 'dir', 'dirxml', // 'table', 'trace', 'clear', 'startGroup', 'startGroupCollapsed', 'endGroup', // 'assert', 'profile', 'profileEnd', 'count', 'timeEnd'. Type string }
ConsoleMessage represents a page console message.
type Cookie ¶
type Cookie struct { Name string `js:"name" json:"name"` // Cookie name. Value string `js:"value" json:"value"` // Cookie value. Domain string `js:"domain" json:"domain"` // Cookie domain. Path string `js:"path" json:"path"` // Cookie path. HTTPOnly bool `js:"httpOnly" json:"httpOnly"` // True if cookie is http-only. Secure bool `js:"secure" json:"secure"` // True if cookie is secure. SameSite CookieSameSite `js:"sameSite" json:"sameSite"` // Cookie SameSite type. URL string `js:"url" json:"url,omitempty"` // Cookie URL. // Cookie expiration date as the number of seconds since the UNIX epoch. Expires int64 `js:"expires" json:"expires"` }
Cookie represents a browser cookie.
type CookieSameSite ¶
type CookieSameSite string
CookieSameSite represents the cookie's 'SameSite' status.
https://tools.ietf.org/html/draft-west-first-party-cookies.
const ( // CookieSameSiteStrict sets the cookie to be sent only in a first-party // context and not be sent along with requests initiated by third party // websites. CookieSameSiteStrict CookieSameSite = "Strict" // CookieSameSiteLax sets the cookie to be sent along with "same-site" // requests, and with "cross-site" top-level navigations. CookieSameSiteLax CookieSameSite = "Lax" // CookieSameSiteNone sets the cookie to be sent in all contexts, i.e // potentially insecure third-party requests. CookieSameSiteNone CookieSameSite = "None" )
type Credentials ¶
Credentials holds HTTP authentication credentials.
func (Credentials) IsEmpty ¶
func (c Credentials) IsEmpty() bool
IsEmpty returns true if the credentials are empty.
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() *ElementHandle
AsElement returns this element handle.
func (*ElementHandle) BoundingBox ¶
func (h *ElementHandle) BoundingBox() *Rect
BoundingBox returns this element's bounding box.
func (*ElementHandle) Check ¶
func (h *ElementHandle) Check(opts *ElementHandleSetCheckedOptions) error
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 *ElementHandleClickOptions) error
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() (*Frame, error)
ContentFrame returns the frame that contains this element.
func (*ElementHandle) Dblclick ¶
func (h *ElementHandle) Dblclick(opts *ElementHandleDblclickOptions) error
Dblclick scrolls element into view and double clicks on the element.
func (*ElementHandle) DefaultTimeout ¶ added in v0.58.0
func (h *ElementHandle) DefaultTimeout() time.Duration
DefaultTimeout returns the default timeout for this element handle.
func (*ElementHandle) DispatchEvent ¶
func (h *ElementHandle) DispatchEvent(typ string, eventInit any) error
DispatchEvent dispatches a DOM event to the element.
func (*ElementHandle) Fill ¶
func (h *ElementHandle) Fill(value string, opts *ElementHandleBaseOptions) error
Fill types the given value into the element.
func (*ElementHandle) Focus ¶
func (h *ElementHandle) Focus() error
Focus scrolls element into view and focuses the element.
func (*ElementHandle) GetAttribute ¶
func (h *ElementHandle) GetAttribute(name string) (string, bool, error)
GetAttribute retrieves the value of specified element attribute. The second return value is true if the attribute exists, and false otherwise.
func (*ElementHandle) Hover ¶
func (h *ElementHandle) Hover(opts *ElementHandleHoverOptions) error
Hover scrolls element into view and hovers over its center point.
func (*ElementHandle) InnerHTML ¶
func (h *ElementHandle) InnerHTML() (string, error)
InnerHTML returns the inner HTML of the element.
func (*ElementHandle) InnerText ¶
func (h *ElementHandle) InnerText() (string, error)
InnerText returns the inner text of the element.
func (*ElementHandle) InputValue ¶
func (h *ElementHandle) InputValue(opts *ElementHandleBaseOptions) (string, error)
InputValue returns the value of the input element.
func (*ElementHandle) IsChecked ¶
func (h *ElementHandle) IsChecked() (bool, error)
IsChecked checks if a checkbox or radio is checked.
func (*ElementHandle) IsDisabled ¶
func (h *ElementHandle) IsDisabled() (bool, error)
IsDisabled checks if the element is disabled.
func (*ElementHandle) IsEditable ¶
func (h *ElementHandle) IsEditable() (bool, error)
IsEditable checks if the element is editable.
func (*ElementHandle) IsEnabled ¶
func (h *ElementHandle) IsEnabled() (bool, error)
IsEnabled checks if the element is enabled.
func (*ElementHandle) IsHidden ¶
func (h *ElementHandle) IsHidden() (bool, error)
IsHidden checks if the element is hidden.
func (*ElementHandle) IsVisible ¶
func (h *ElementHandle) IsVisible() (bool, error)
IsVisible checks if the element is visible.
func (*ElementHandle) OwnerFrame ¶
func (h *ElementHandle) OwnerFrame() (_ *Frame, rerr error)
OwnerFrame returns the frame containing this element.
func (*ElementHandle) Press ¶
func (h *ElementHandle) Press(key string, opts *ElementHandlePressOptions) error
Press scrolls element into view and presses the given keys.
func (*ElementHandle) Query ¶
func (h *ElementHandle) Query(selector string, strict bool) (_ *ElementHandle, rerr error)
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) ([]*ElementHandle, error)
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 *ElementHandleScreenshotOptions, sp ScreenshotPersister, ) ([]byte, error)
Screenshot will instruct Chrome to save a screenshot of the current element and save it to specified file.
func (*ElementHandle) ScrollIntoViewIfNeeded ¶
func (h *ElementHandle) ScrollIntoViewIfNeeded(opts *ElementHandleBaseOptions) error
ScrollIntoViewIfNeeded scrolls element into view if needed.
func (*ElementHandle) SelectOption ¶
func (h *ElementHandle) SelectOption(values []any, opts *ElementHandleBaseOptions) ([]string, error)
SelectOption selects the options matching the given values.
func (*ElementHandle) SelectText ¶
func (h *ElementHandle) SelectText(opts *ElementHandleBaseOptions) error
SelectText selects the text of the element.
func (*ElementHandle) SetChecked ¶
func (h *ElementHandle) SetChecked(checked bool, opts *ElementHandleSetCheckedOptions) error
SetChecked checks or unchecks an element.
func (*ElementHandle) SetInputFiles ¶
func (h *ElementHandle) SetInputFiles(files *Files, opts *ElementHandleSetInputFilesOptions) error
SetInputFiles sets the given files into the input file element.
func (*ElementHandle) Tap ¶
func (h *ElementHandle) Tap(opts *ElementHandleTapOptions) error
Tap scrolls element into view and taps in the center of the element.
func (*ElementHandle) TextContent ¶
func (h *ElementHandle) TextContent() (string, bool, error)
TextContent returns the text content of the element. The second return value is true if the text content exists, and false otherwise.
func (*ElementHandle) Timeout ¶
func (h *ElementHandle) Timeout() time.Duration
Timeout will return the default timeout or the one set by the user. It's an internal method not to be exposed as a JS API.
func (*ElementHandle) Type ¶
func (h *ElementHandle) Type(text string, opts *ElementHandleTypeOptions) error
Type scrolls element into view, focuses element and types text.
func (*ElementHandle) Uncheck ¶
func (h *ElementHandle) Uncheck(opts *ElementHandleSetCheckedOptions) error
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 *ElementHandleWaitForElementStateOptions) error
WaitForElementState waits for the element to reach the given state.
func (*ElementHandle) WaitForSelector ¶
func (h *ElementHandle) WaitForSelector(selector string, opts *FrameWaitForSelectorOptions) (*ElementHandle, error)
WaitForSelector waits for the selector to appear in the DOM.
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) Parse ¶
Parse parses the ElementHandleClickOptions from the given opts.
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 ¶
Parse parses the ElementHandleDblclickOptions from the given opts.
func (*ElementHandleDblclickOptions) ToMouseClickOptions ¶
func (o *ElementHandleDblclickOptions) ToMouseClickOptions() *MouseClickOptions
type ElementHandleDispatchEventOptions ¶
type ElementHandleDispatchEventOptions struct {
*ElementHandleBaseOptions
}
ElementHandleDispatchEventOptions are options for ElementHandle.dispatchEvent.
func NewElementHandleDispatchEventOptions ¶
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) Parse ¶
Parse parses the ElementHandlePressOptions from the given opts.
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 ElementHandleSetInputFilesOptions ¶
type ElementHandleSetInputFilesOptions struct {
ElementHandleBaseOptions
}
ElementHandleSetInputFilesOptions are options for ElementHandle.SetInputFiles.
func NewElementHandleSetInputFilesOptions ¶
func NewElementHandleSetInputFilesOptions(defaultTimeout time.Duration) *ElementHandleSetInputFilesOptions
NewElementHandleSetInputFilesOptions creates a new ElementHandleSetInputFilesOption.
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) Parse ¶
Parse parses the ElementHandleTypeOptions from the given opts.
func (*ElementHandleTypeOptions) ToBaseOptions ¶
func (o *ElementHandleTypeOptions) ToBaseOptions() *ElementHandleBaseOptions
type ElementHandleWaitForElementStateOptions ¶
func NewElementHandleWaitForElementStateOptions ¶
func NewElementHandleWaitForElementStateOptions(defaultTimeout time.Duration) *ElementHandleWaitForElementStateOptions
type EmulatedSize ¶
EmulatedSize represents the emulated viewport and screen sizes.
func NewEmulatedSize ¶
func NewEmulatedSize(viewport Viewport, screen Screen) *EmulatedSize
NewEmulatedSize creates and returns a new 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 ¶
Eval evaluates the provided JavaScript within this execution context and returns a value or handle.
func (*ExecutionContext) EvalHandle ¶
func (e *ExecutionContext) EvalHandle(apiCtx context.Context, js string, args ...any) (JSHandleAPI, 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 ¶
func (e *ExecutionContext) ID() runtime.ExecutionContextID
ID returns the CDP runtime ID of this execution context.
type File ¶
type File struct { Name string `json:"name"` Mimetype string `json:"mimeType"` Buffer string `json:"buffer"` }
File is the descriptor of a single file.
type Files ¶
type Files struct {
Payload []*File `json:"payload"`
}
Files is the input parameter for ElementHandle.SetInputFiles.
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) Check ¶
func (f *Frame) Check(selector string, popts *FrameCheckOptions) error
Check clicks the first element found that matches selector.
func (*Frame) ChildFrames ¶
ChildFrames returns a list of child frames.
func (*Frame) Click ¶
func (f *Frame) Click(selector string, opts *FrameClickOptions) error
Click clicks the first element found that matches selector.
func (*Frame) Dblclick ¶
func (f *Frame) Dblclick(selector string, popts *FrameDblclickOptions) error
Dblclick double clicks an element matching provided selector.
func (*Frame) DispatchEvent ¶
func (f *Frame) DispatchEvent(selector, typ string, eventInit any, opts *FrameDispatchEventOptions) error
DispatchEvent dispatches an event for the first element matching the selector.
func (*Frame) EvaluateGlobal ¶
EvaluateGlobal will evaluate the given JS code in the global object.
func (*Frame) EvaluateHandle ¶
func (f *Frame) EvaluateHandle(pageFunc string, args ...any) (handle JSHandleAPI, _ error)
EvaluateHandle will evaluate provided page function within an execution context.
func (*Frame) EvaluateWithContext ¶
EvaluateWithContext will evaluate provided page function within an execution context. The passed in context will be used instead of the frame's context. The context must be a derivative of one that contains the sobek runtime.
func (*Frame) Fill ¶
func (f *Frame) Fill(selector, value string, popts *FrameFillOptions) error
Fill fills out the first element found that matches the selector.
func (*Frame) Focus ¶
func (f *Frame) Focus(selector string, popts *FrameBaseOptions) error
Focus focuses on the first element that matches the selector.
func (*Frame) FrameElement ¶
func (f *Frame) FrameElement() (*ElementHandle, error)
FrameElement returns the element handle for the frame.
func (*Frame) GetAttribute ¶
GetAttribute of the first element found that matches the selector. The second return value is true if the attribute exists, and false otherwise.
func (*Frame) Goto ¶
func (f *Frame) Goto(url string, opts *FrameGotoOptions) (*Response, error)
Goto will navigate the frame to the specified URL and return a HTTP response object.
func (*Frame) Hover ¶
func (f *Frame) Hover(selector string, popts *FrameHoverOptions) error
Hover moves the pointer over the first element that matches the selector.
func (*Frame) InnerHTML ¶
func (f *Frame) InnerHTML(selector string, popts *FrameInnerHTMLOptions) (string, error)
InnerHTML returns the innerHTML attribute of the first element found that matches the selector.
func (*Frame) InnerText ¶
func (f *Frame) InnerText(selector string, popts *FrameInnerTextOptions) (string, error)
InnerText returns the inner text of the first element found that matches the selector.
func (*Frame) InputValue ¶
func (f *Frame) InputValue(selector string, popts *FrameInputValueOptions) (string, error)
InputValue returns the input value of the first element found that matches the selector.
func (*Frame) IsChecked ¶
func (f *Frame) IsChecked(selector string, opts *FrameIsCheckedOptions) (bool, error)
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 ¶
func (f *Frame) IsDisabled(selector string, opts *FrameIsDisabledOptions) (bool, error)
IsDisabled returns true if the first element that matches the selector is disabled. Otherwise, returns false.
func (*Frame) IsEditable ¶
func (f *Frame) IsEditable(selector string, opts *FrameIsEditableOptions) (bool, error)
IsEditable returns true if the first element that matches the selector is editable. Otherwise, returns false.
func (*Frame) IsEnabled ¶
func (f *Frame) IsEnabled(selector string, opts *FrameIsEnabledOptions) (bool, error)
IsEnabled returns true if the first element that matches the selector is enabled. Otherwise, returns false.
func (*Frame) IsHidden ¶
func (f *Frame) IsHidden(selector string, opts *FrameIsHiddenOptions) (bool, error)
IsHidden returns true if the first element that matches the selector is hidden. Otherwise, returns false.
func (*Frame) IsVisible ¶
func (f *Frame) IsVisible(selector string, opts *FrameIsVisibleOptions) (bool, error)
IsVisible returns true if the first element that matches the selector is visible. Otherwise, returns false.
func (*Frame) NavigationTimeout ¶
NavigationTimeout returns the navigation timeout of the frame. It's an internal method not to be exposed as a JS API.
func (*Frame) ParentFrame ¶
ParentFrame returns the parent frame, if one exists.
func (*Frame) Press ¶
func (f *Frame) Press(selector, key string, opts *FramePressOptions) error
Press presses the given key for the first element found that matches the selector.
func (*Frame) Query ¶
func (f *Frame) Query(selector string, strict bool) (*ElementHandle, error)
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) ([]*ElementHandle, error)
QueryAll runs a selector query against the document tree, returning all matching elements.
func (*Frame) Referrer ¶
Referrer returns the referrer of the frame from the network manager of the frame's session. It's an internal method not to be exposed as a JS API.
func (*Frame) SelectOption ¶
func (f *Frame) SelectOption(selector string, values []any, popts *FrameSelectOptionOptions) ([]string, error)
SelectOption selects the given options and returns the array of option values of the first element found that matches the selector.
func (*Frame) SetChecked ¶
func (f *Frame) SetChecked(selector string, checked bool, popts *FrameCheckOptions) error
SetChecked sets the checked state of the first element found that matches the selector.
func (*Frame) SetContent ¶
func (f *Frame) SetContent(html string, _ *FrameSetContentOptions) error
SetContent replaces the entire HTML document content.
func (*Frame) SetInputFiles ¶
func (f *Frame) SetInputFiles(selector string, pfiles *Files, popts *FrameSetInputFilesOptions) error
SetInputFiles sets input files for the selected element.
func (*Frame) Tap ¶
func (f *Frame) Tap(selector string, opts *FrameTapOptions) error
Tap the first element that matches the selector.
func (*Frame) TextContent ¶
TextContent returns the textContent attribute of the first element found that matches the selector. The second return value is true if the returned text content is not null or empty, and false otherwise.
func (*Frame) Timeout ¶
Timeout will return the default timeout or the one set by the user. It's an internal method not to be exposed as a JS API.
func (*Frame) Type ¶
func (f *Frame) Type(selector, text string, popts *FrameTypeOptions) error
Type text on the first element found matches the selector.
func (*Frame) Uncheck ¶
func (f *Frame) Uncheck(selector string, popts *FrameUncheckOptions) error
Uncheck the first found element that matches the selector.
func (*Frame) WaitForFunction ¶
func (f *Frame) WaitForFunction(js string, opts *FrameWaitForFunctionOptions, jsArgs ...any) (any, error)
WaitForFunction waits for the given predicate to return a truthy value.
func (*Frame) WaitForLoadState ¶
func (f *Frame) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error
WaitForLoadState waits for the given load state to be reached. This will unblock if that lifecycle event has already been received.
func (*Frame) WaitForNavigation ¶
func (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions) (*Response, error)
WaitForNavigation waits for the given navigation lifecycle event to happen.
func (*Frame) WaitForSelector ¶
func (f *Frame) WaitForSelector(selector string, popts *FrameWaitForSelectorOptions) (*ElementHandle, error)
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 ¶
type FrameDispatchEventOptions struct {
*FrameBaseOptions
}
FrameDispatchEventOptions are options for Frame.dispatchEvent.
func NewFrameDispatchEventOptions ¶
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" js:"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 {
Strict bool `json:"strict"`
}
func NewFrameIsHiddenOptions ¶
func NewFrameIsHiddenOptions() *FrameIsHiddenOptions
NewFrameIsHiddenOptions creates and returns a new instance of FrameIsHiddenOptions.
type FrameIsVisibleOptions ¶
type FrameIsVisibleOptions struct {
Strict bool `json:"strict"`
}
func NewFrameIsVisibleOptions ¶
func NewFrameIsVisibleOptions() *FrameIsVisibleOptions
NewFrameIsVisibleOptions creates and returns a new instance of FrameIsVisibleOptions.
type FrameLifecycleEvent ¶
type FrameLifecycleEvent struct { // URL is the URL of the frame that emitted the event. URL string // Event is the lifecycle event that occurred. Event LifecycleEvent }
FrameLifecycleEvent is emitted when a frame lifecycle event occurs.
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() []*Frame
Frames returns a list of frames on the page.
func (*FrameManager) ID ¶
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) MainFrameURL ¶
func (m *FrameManager) MainFrameURL() string
MainFrameURL returns the main frame's url.
func (*FrameManager) NavigateFrame ¶
func (m *FrameManager) NavigateFrame(frame *Frame, url string, parsedOpts *FrameGotoOptions) (*Response, error)
NavigateFrame will navigate specified frame to specified URL.
func (*FrameManager) Page ¶
func (m *FrameManager) Page() *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
ToKeyboardOptions converts FramePressOptions to KeyboardOptions.
type FrameSelectOptionOptions ¶
type FrameSelectOptionOptions struct { ElementHandleBaseOptions Strict bool `json:"strict"` }
func NewFrameSelectOptionOptions ¶
func NewFrameSelectOptionOptions(defaultTimeout time.Duration) *FrameSelectOptionOptions
NewFrameSelectOptionOptions creates and returns a new instance of 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, hasUIWindow bool, ) (_ *FrameSession, err error)
NewFrameSession initializes and returns a new FrameSession.
type FrameSetContentOptions ¶
type FrameSetContentOptions struct { Timeout time.Duration `json:"timeout"` WaitUntil LifecycleEvent `json:"waitUntil" js:"waitUntil"` }
func NewFrameSetContentOptions ¶
func NewFrameSetContentOptions(defaultTimeout time.Duration) *FrameSetContentOptions
type FrameSetInputFilesOptions ¶
type FrameSetInputFilesOptions struct { ElementHandleSetInputFilesOptions Strict bool `json:"strict"` }
FrameSetInputFilesOptions are options for Frame.setInputFiles.
func NewFrameSetInputFilesOptions ¶
func NewFrameSetInputFilesOptions(defaultTimeout time.Duration) *FrameSetInputFilesOptions
NewFrameSetInputFilesOptions creates a new FrameSetInputFilesOptions.
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
ToKeyboardOptions converts FrameTypeOptions to 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"` Accuracy float64 `js:"accuracy"` }
Geolocation represents a geolocation.
func (*Geolocation) Validate ¶
func (g *Geolocation) Validate() error
Validate validates the Geolocation.
type GrantPermissionsOptions ¶
type GrantPermissionsOptions struct {
Origin string
}
GrantPermissionsOptions is used by BrowserContext.GrantPermissions.
type HTTPHeader ¶
HTTPHeader is a single HTTP header.
type HTTPMessageSize ¶
HTTPMessageSize are the sizes in bytes of the HTTP message header and body.
func (HTTPMessageSize) Total ¶
func (s HTTPMessageSize) Total() int64
Total returns the total size in bytes of the HTTP message.
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 JSHandleAPI ¶
type JSHandleAPI interface { AsElement() *ElementHandle Dispose() error Evaluate(pageFunc string, args ...any) (any, error) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error) GetProperties() (map[string]JSHandleAPI, error) JSONValue() (string, error) ObjectID() runtime.RemoteObjectID }
JSHandleAPI is the interface of an in-page JS object.
TODO: Find a way to move this to a concrete type. It's too difficult to do that right now because of the tests and the way we're using the JSHandleAPI interface.
type K6BrowserCheckRegEx ¶
K6BrowserCheckRegEx is a function that will be used to check the URL tag against the user defined regexes in the Sobek runtime.
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 ¶
func (k *Keyboard) Press(key string, kbdOpts KeyboardOptions) error
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, kbdOpts KeyboardOptions) error
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.
type KeyboardOptions ¶
type KeyboardOptions struct {
Delay int64 `json:"delay"`
}
KeyboardOptions represents the options for the keyboard.
type LifecycleEvent ¶
type LifecycleEvent int
LifecycleEvent is a lifecycle event.
const ( // LifecycleEventLoad is emitted when the page load event is fired. LifecycleEventLoad LifecycleEvent = iota // LifecycleEventDOMContentLoad is emitted when the DOMContentLoaded event is fired. LifecycleEventDOMContentLoad // LifecycleEventNetworkIdle is emitted when there are no more than 2 network connections for at least 500 ms. LifecycleEventNetworkIdle )
func (LifecycleEvent) MarshalJSON ¶
func (l LifecycleEvent) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted JSON string.
func (*LifecycleEvent) MarshalText ¶
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 ¶
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 ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator represent a way to find element(s) on the page at any moment.
func NewLocator ¶
NewLocator creates and returns a new locator.
func (*Locator) Clear ¶
func (l *Locator) Clear(opts *FrameFillOptions) error
Clear will clear the input field. This works with the Fill API and fills the input field with an empty string.
func (*Locator) Click ¶
func (l *Locator) Click(opts *FrameClickOptions) error
Click on an element using locator's selector with strict mode on.
func (*Locator) Dblclick ¶
Dblclick double clicks on an element using locator's selector with strict mode on.
func (*Locator) DefaultTimeout ¶
DefaultTimeout returns the default timeout for the locator. This is an internal API and should not be used by users.
func (*Locator) DispatchEvent ¶
func (l *Locator) DispatchEvent(typ string, eventInit any, opts *FrameDispatchEventOptions) error
DispatchEvent dispatches an event for the element matching the locator's selector with strict mode on.
func (*Locator) GetAttribute ¶
GetAttribute of the element using locator's selector with strict mode on. The second return value is true if the attribute exists, and false otherwise.
func (*Locator) Hover ¶
Hover moves the pointer over the element that matches the locator's selector with strict mode on.
func (*Locator) InnerHTML ¶
InnerHTML returns the element's inner HTML that matches the locator's selector with strict mode on.
func (*Locator) InnerText ¶
InnerText returns the element's inner text that matches the locator's selector with strict mode on.
func (*Locator) InputValue ¶
InputValue returns the element's input value that matches the locator's selector with strict mode on.
func (*Locator) IsChecked ¶
IsChecked returns true if the element matches the locator's selector and is checked. Otherwise, returns false.
func (*Locator) IsDisabled ¶
IsDisabled returns true if the element matches the locator's selector and is disabled. Otherwise, returns false.
func (*Locator) IsEditable ¶
IsEditable returns true if the element matches the locator's selector and is Editable. Otherwise, returns false.
func (*Locator) IsEnabled ¶
IsEnabled returns true if the element matches the locator's selector and is Enabled. Otherwise, returns false.
func (*Locator) IsHidden ¶
IsHidden returns true if the element matches the locator's selector and is hidden. Otherwise, returns false.
func (*Locator) IsVisible ¶
IsVisible returns true if the element matches the locator's selector and is visible. Otherwise, returns false.
func (*Locator) Press ¶
Press the given key on the element found that matches the locator's selector with strict mode on.
func (*Locator) SelectOption ¶
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) SetChecked ¶
SetChecked sets the checked state of the element using locator's selector with strict mode on.
func (*Locator) Tap ¶
func (l *Locator) Tap(opts *FrameTapOptions) error
Tap the element found that matches the locator's selector with strict mode on.
func (*Locator) TextContent ¶
TextContent returns the element's text content that matches the locator's selector with strict mode on. The second return value is true if the returned text content is not null or empty, and false otherwise.
func (*Locator) Type ¶
Type text on the element found that matches the locator's selector with strict mode on.
type Match ¶
type Match struct { // This is a regex that will be compared against the existing url tag. URLRegEx string `js:"url"` // This is the request method to match on. Method string `js:"method"` }
Match contains the fields that will be used to match against metric tags that are about to be emitted.
type MetricEvent ¶
type MetricEvent struct {
// contains filtered or unexported fields
}
MetricEvent is the type that is exported to JS. It is currently only used to match on the urlTag and return a name when a match is found.
func (*MetricEvent) Tag ¶
func (e *MetricEvent) Tag(matchesRegex K6BrowserCheckRegEx, matches TagMatches) error
Tag will find the first match given the URLTagPatterns and the URL from the metric tag and update the name field.
type Mouse ¶
type Mouse struct {
// contains filtered or unexported fields
}
Mouse represents a mouse input device.
func (*Mouse) Click ¶
func (m *Mouse) Click(x float64, y float64, opts *MouseClickOptions) error
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 *MouseDblClickOptions) error
DblClick will trigger Click twice in quick succession.
func (*Mouse) Down ¶
func (m *Mouse) Down(opts *MouseDownUpOptions) error
Down will trigger a MouseDown event in the browser.
func (*Mouse) Move ¶
func (m *Mouse) Move(x float64, y float64, opts *MouseMoveOptions) error
Move will trigger a MouseMoved event in the browser.
func (*Mouse) Up ¶
func (m *Mouse) Up(opts *MouseDownUpOptions) error
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) ToMouseDownUpOptions ¶
func (o *MouseClickOptions) ToMouseDownUpOptions() *MouseDownUpOptions
type MouseDblClickOptions ¶
func NewMouseDblClickOptions ¶
func NewMouseDblClickOptions() *MouseDblClickOptions
func (*MouseDblClickOptions) ToMouseClickOptions ¶
func (o *MouseDblClickOptions) ToMouseClickOptions() *MouseClickOptions
ToMouseClickOptions converts MouseDblClickOptions to a MouseClickOptions.
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, customMetrics *k6ext.CustomMetrics, s session, fm *FrameManager, parent *NetworkManager, ei eventInterceptor, ) (*NetworkManager, error)
NewNetworkManager creates a new network manager.
func (*NetworkManager) Authenticate ¶
func (m *NetworkManager) Authenticate(credentials Credentials) error
Authenticate sets HTTP authentication credentials to use.
func (*NetworkManager) SetCacheEnabled ¶
func (m *NetworkManager) SetCacheEnabled(enabled bool)
SetCacheEnabled toggles cache on/off.
func (*NetworkManager) SetExtraHTTPHeaders ¶
func (m *NetworkManager) SetExtraHTTPHeaders(headers network.Headers) error
SetExtraHTTPHeaders sets extra HTTP request headers to be sent with every request.
func (*NetworkManager) SetOfflineMode ¶
func (m *NetworkManager) SetOfflineMode(offline bool) error
SetOfflineMode toggles offline mode on/off.
func (*NetworkManager) SetUserAgent ¶
func (m *NetworkManager) SetUserAgent(userAgent string)
SetUserAgent overrides the browser user agent string.
func (*NetworkManager) ThrottleNetwork ¶
func (m *NetworkManager) ThrottleNetwork(networkProfile NetworkProfile) error
ThrottleNetwork changes the network attributes in chrome to simulate slower networks e.g. a slow 3G connection.
type NetworkProfile ¶
type NetworkProfile struct { // Minimum latency from request sent to response headers received (ms). Latency float64 // Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. Download float64 // Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. Upload float64 }
NetworkProfile is used in ThrottleNetwork.
func NewNetworkProfile ¶
func NewNetworkProfile() NetworkProfile
NewNetworkProfile creates a non-throttled network profile.
type NewRequestParams ¶
type NewRequestParams struct {
// contains filtered or unexported fields
}
NewRequestParams are input parameters for NewRequest.
type Page ¶
type Page struct { Keyboard *Keyboard Mouse *Mouse Touchscreen *Touchscreen // 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) BringToFront ¶
BringToFront activates the browser tab for this page.
func (*Page) Check ¶
func (p *Page) Check(selector string, popts *FrameCheckOptions) error
Check checks an element matching the provided selector.
func (*Page) Click ¶
func (p *Page) Click(selector string, opts *FrameClickOptions) error
Click clicks an element matching provided selector.
func (*Page) Dblclick ¶
func (p *Page) Dblclick(selector string, popts *FrameDblclickOptions) error
Dblclick double clicks an element matching provided selector.
func (*Page) DispatchEvent ¶
func (p *Page) DispatchEvent(selector string, typ string, eventInit any, opts *FrameDispatchEventOptions) error
DispatchEvent dispatches an event on the page to the element that matches the provided selector.
func (*Page) EmulateMedia ¶
func (p *Page) EmulateMedia(popts *PageEmulateMediaOptions) error
EmulateMedia emulates the given media type.
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 (p *Page) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error)
EvaluateHandle runs JS code within the execution context of the main frame of the page.
func (*Page) Fill ¶
func (p *Page) Fill(selector string, value string, popts *FrameFillOptions) error
Fill fills an input element with the provided value.
func (*Page) Focus ¶
func (p *Page) Focus(selector string, popts *FrameBaseOptions) error
Focus focuses an element matching the provided selector.
func (*Page) GetAttribute ¶
func (p *Page) GetAttribute(selector string, name string, popts *FrameBaseOptions) (string, bool, error)
GetAttribute returns the attribute value of the element matching the provided selector. The second return value is true if the attribute exists, and false otherwise.
func (*Page) GetKeyboard ¶
GetKeyboard returns the keyboard for the page.
func (*Page) GetTouchscreen ¶
func (p *Page) GetTouchscreen() *Touchscreen
GetTouchscreen returns the touchscreen for the page.
func (*Page) Goto ¶
func (p *Page) Goto(url string, opts *FrameGotoOptions) (*Response, error)
Goto will navigate the page to the specified URL and return a HTTP response object.
func (*Page) Hover ¶
func (p *Page) Hover(selector string, popts *FrameHoverOptions) error
Hover hovers over an element matching the provided selector.
func (*Page) InnerHTML ¶
func (p *Page) InnerHTML(selector string, popts *FrameInnerHTMLOptions) (string, error)
InnerHTML returns the inner HTML of the element matching the provided selector.
func (*Page) InnerText ¶
func (p *Page) InnerText(selector string, popts *FrameInnerTextOptions) (string, error)
InnerText returns the inner text of the element matching the provided selector.
func (*Page) InputValue ¶
func (p *Page) InputValue(selector string, popts *FrameInputValueOptions) (string, error)
InputValue returns the value of the input element matching the provided selector.
func (*Page) IsChecked ¶
func (p *Page) IsChecked(selector string, opts *FrameIsCheckedOptions) (bool, error)
IsChecked returns true if the first element that matches the selector is checked. Otherwise, returns false.
func (*Page) IsDisabled ¶
func (p *Page) IsDisabled(selector string, opts *FrameIsDisabledOptions) (bool, error)
IsDisabled returns true if the first element that matches the selector is disabled. Otherwise, returns false.
func (*Page) IsEditable ¶
func (p *Page) IsEditable(selector string, opts *FrameIsEditableOptions) (bool, error)
IsEditable returns true if the first element that matches the selector is editable. Otherwise, returns false.
func (*Page) IsEnabled ¶
func (p *Page) IsEnabled(selector string, opts *FrameIsEnabledOptions) (bool, error)
IsEnabled returns true if the first element that matches the selector is enabled. Otherwise, returns false.
func (*Page) IsHidden ¶
func (p *Page) IsHidden(selector string, opts *FrameIsHiddenOptions) (bool, error)
IsHidden will look for an element in the dom with given selector and see if the element is hidden. It will not wait for a match to occur. If no elements match `false` will be returned.
func (*Page) IsVisible ¶
func (p *Page) IsVisible(selector string, opts *FrameIsVisibleOptions) (bool, error)
IsVisible will look for an element in the dom with given selector. It will not wait for a match to occur. If no elements match `false` will be returned.
func (*Page) NavigationTimeout ¶
NavigationTimeout returns the page's navigation timeout. It's an internal method not to be exposed as a JS API.
func (*Page) On ¶
func (p *Page) On(event PageOnEventName, handler PageOnHandler) error
On subscribes to a page event for which the given handler will be executed passing in the ConsoleMessage associated with the event. The only accepted event value is 'console'.
func (*Page) Press ¶
func (p *Page) Press(selector string, key string, opts *FramePressOptions) error
Press presses the given key for the first element found that matches the selector.
func (*Page) Query ¶
func (p *Page) Query(selector string) (*ElementHandle, error)
Query returns the first element matching the specified selector.
func (*Page) QueryAll ¶
func (p *Page) QueryAll(selector string) ([]*ElementHandle, error)
QueryAll returns all elements matching the specified selector.
func (*Page) Referrer ¶
Referrer returns the page's referrer. It's an internal method not to be exposed as a JS API.
func (*Page) Reload ¶
func (p *Page) Reload(opts *PageReloadOptions) (*Response, error)
Reload will reload the current page.
func (*Page) Screenshot ¶
func (p *Page) Screenshot(opts *PageScreenshotOptions, sp ScreenshotPersister) ([]byte, error)
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 []any, popts *FrameSelectOptionOptions) ([]string, error)
SelectOption selects the given options and returns the array of option values of the first element found that matches the selector.
func (*Page) SetChecked ¶
func (p *Page) SetChecked(selector string, checked bool, popts *FrameCheckOptions) error
SetChecked sets the checked state of the element matching the provided selector.
func (*Page) SetContent ¶
func (p *Page) SetContent(html string, opts *FrameSetContentOptions) error
SetContent replaces the entire HTML document content.
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 (p *Page) SetInputFiles(selector string, files *Files, opts *FrameSetInputFilesOptions) error
SetInputFiles sets input files for the selected element.
func (*Page) SetViewportSize ¶
SetViewportSize will update the viewport width and height.
func (*Page) Tap ¶
func (p *Page) Tap(selector string, opts *FrameTapOptions) error
Tap will tap the element matching the provided selector.
func (*Page) TargetID ¶
TargetID retrieve the unique id that is associated to this page. For internal use only.
func (*Page) TextContent ¶
TextContent returns the textContent attribute of the first element found that matches the selector. The second return value is true if the returned text content is not null or empty, and false otherwise.
func (*Page) ThrottleCPU ¶
func (p *Page) ThrottleCPU(cpuProfile CPUProfile) error
ThrottleCPU will slow the CPU down from chrome's perspective to simulate a test being run on a slower device.
func (*Page) ThrottleNetwork ¶
func (p *Page) ThrottleNetwork(networkProfile NetworkProfile) error
ThrottleNetwork will slow the network down to simulate a slow network e.g. simulating a slow 3G connection.
func (*Page) Timeout ¶
Timeout will return the default timeout or the one set by the user. It's an internal method not to be exposed as a JS API.
func (*Page) Type ¶
func (p *Page) Type(selector string, text string, popts *FrameTypeOptions) error
Type text on the first element found matches the selector.
func (*Page) Uncheck ¶
func (p *Page) Uncheck(selector string, popts *FrameUncheckOptions) error
Uncheck unchecks an element matching the provided selector.
func (*Page) ViewportSize ¶
ViewportSize will return information on the viewport width and height.
func (*Page) WaitForFunction ¶
func (p *Page) WaitForFunction(js string, opts *FrameWaitForFunctionOptions, jsArgs ...any) (any, error)
WaitForFunction waits for the given predicate to return a truthy value.
func (*Page) WaitForLoadState ¶
func (p *Page) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error
WaitForLoadState waits for the specified page life cycle event.
func (*Page) WaitForNavigation ¶
func (p *Page) WaitForNavigation(opts *FrameWaitForNavigationOptions) (*Response, error)
WaitForNavigation waits for the given navigation lifecycle event to happen.
func (*Page) WaitForSelector ¶
func (p *Page) WaitForSelector(selector string, popts *FrameWaitForSelectorOptions) (*ElementHandle, error)
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(from *Page) *PageEmulateMediaOptions
type PageOnEvent ¶
type PageOnEvent struct { // ConsoleMessage is the console message event. ConsoleMessage *ConsoleMessage // Metric is the metric event event. Metric *MetricEvent // Request is the read only request that is about to be sent from the // browser to the WuT. Request *Request // Response is the read only response that was received from the WuT. Response *Response }
PageOnEvent represents a generic page event. Use one of the fields to get the specific event data.
type PageOnEventName ¶
type PageOnEventName string
PageOnEventName represents the name of the page.on event.
const ( // EventPageConsoleAPICalled represents the page.on('console') event. EventPageConsoleAPICalled PageOnEventName = "console" // EventPageMetricCalled represents the page.on('metric') event. EventPageMetricCalled PageOnEventName = "metric" // EventPageRequestCalled represents the page.on('request') event. EventPageRequestCalled PageOnEventName = "request" // EventPageResponseCalled represents the page.on('response') event. EventPageResponseCalled PageOnEventName = "response" )
type PageOnHandler ¶
type PageOnHandler func(PageOnEvent) error
type PageReloadOptions ¶
type PageReloadOptions struct { WaitUntil LifecycleEvent `json:"waitUntil" js:"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
PollingType is the type of polling to use.
const ( // PollingRaf is the requestAnimationFrame polling type. PollingRaf PollingType = iota // PollingMutation is the mutation polling type. PollingMutation // PollingInterval is the interval polling type. 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 Rect ¶
type Rect struct { X float64 `js:"x"` Y float64 `js:"y"` Width float64 `js:"width"` Height float64 `js:"height"` }
Rect represents a rectangle.
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" js:"ipAddress"` Port int64 `json:"port" js:"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 ¶
NewRequest creates a new HTTP request.
func (*Request) AllHeaders ¶
AllHeaders returns all the request headers.
func (*Request) HeaderValue ¶
HeaderValue returns the value of the given header.
func (*Request) HeadersArray ¶
func (r *Request) HeadersArray() []HTTPHeader
HeadersArray returns the request headers as an array of objects.
func (*Request) IsNavigationRequest ¶
IsNavigationRequest returns whether this was a navigation request or not.
func (*Request) PostData ¶
PostData returns the request post data, if any.
If will not attempt to fetch the data if it should have some but nothing is cached locally: https://go.k6.io/k6/js/modules/k6/browser/issues/1470
This relies on PostDataEntries. It will only ever return the 0th entry. TODO: Create a PostDataEntries API when we have a better idea of when that is needed.
func (*Request) PostDataBuffer ¶
PostDataBuffer returns the request post data as an ArrayBuffer.
If will not attempt to fetch the data if it should have some but nothing is cached locally: https://go.k6.io/k6/js/modules/k6/browser/issues/1470
This relies on PostDataEntries. It will only ever return the 0th entry. TODO: Create a PostDataEntries API when we have a better idea of when that is needed.
func (*Request) ResourceType ¶
ResourceType returns the request resource type.
func (*Request) Size ¶
func (r *Request) Size() HTTPMessageSize
Size returns the size of the request.
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 ¶
AllHeaders returns all the response headers.
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) HeaderValue ¶
HeaderValue returns the value of the given header. Returns true if the header is present, false otherwise.
func (*Response) HeaderValues ¶
HeaderValues returns the values of the given header.
func (*Response) HeadersArray ¶
func (r *Response) HeadersArray() []HTTPHeader
HeadersArray returns the response headers as an array of objects.
func (*Response) Ok ¶
Ok returns true if status code of response if considered ok, otherwise returns false.
func (*Response) SecurityDetails ¶
func (r *Response) SecurityDetails() *SecurityDetails
SecurityDetails returns the security details of the response.
func (*Response) ServerAddr ¶
func (r *Response) ServerAddr() *RemoteAddress
ServerAddr returns the remote address of the server.
func (*Response) Size ¶
func (r *Response) Size() HTTPMessageSize
Size returns the size in bytes of the response.
func (*Response) StatusText ¶
StatusText returns the response status text.
type ScreenshotPersister ¶
type ScreenshotPersister interface {
Persist(ctx context.Context, path string, data io.Reader) (err error)
}
ScreenshotPersister is the type that all file persisters must implement. It's job is to persist a file somewhere, hiding the details of where and how from the caller.
type ScrollIntoViewOptions ¶
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 ¶
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" js:"subjectName"` Issuer string `json:"issuer" js:"issuer"` ValidFrom int64 `json:"validFrom" js:"validFrom"` ValidTo int64 `json:"validTo" js:"validTo"` Protocol string `json:"protocol" js:"protocol"` SANList []string `json:"sanList" js:"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"` }
SelectOption represents a select option.
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, msgIDGen msgIDGenerator, ) *Session
NewSession creates a new session.
func (*Session) Done ¶
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 Size ¶
Size represents a size.
type TagMatches ¶
type TagMatches struct { // The name to send back to the caller of the handler. TagName string `js:"name"` // The patterns to match against. Matches []Match `js:"matches"` }
TagMatches contains the name tag and matches used to match against existing metric tags that are about to be emitted.
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 {
// 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.
type Tracer ¶
type Tracer interface { TraceAPICall( ctx context.Context, targetID string, spanName string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span) ctx context.Context, targetID string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span) TraceEvent( ctx context.Context, targetID string, eventName string, spanID string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span) }
Tracer defines the interface with the tracing methods used in the common package.
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.
Source Files
¶
- barrier.go
- browser.go
- browser_context.go
- browser_context_options.go
- browser_options.go
- browser_process.go
- browser_process_meta.go
- connection.go
- consts.go
- context.go
- device.go
- doc.go
- element_handle.go
- element_handle_options.go
- errors.go
- event_emitter.go
- execution_context.go
- frame.go
- frame_manager.go
- frame_options.go
- frame_session.go
- helpers.go
- hooks.go
- http.go
- js_handle.go
- keyboard.go
- kill_linux.go
- layout.go
- lifecycle.go
- locator.go
- mouse.go
- mouse_options.go
- network_manager.go
- network_profile.go
- page.go
- page_options.go
- remote_object.go
- screenshotter.go
- selectors.go
- session.go
- timeout.go
- touchscreen.go
- trace.go
- worker.go