Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
type Browser interface { Close() Contexts() []BrowserContext IsConnected() bool NewContext(opts goja.Value) BrowserContext NewPage(opts goja.Value) Page On(string) (bool, error) UserAgent() string Version() string }
Browser is the public interface of a CDP browser.
type BrowserContext ¶
type BrowserContext interface { AddCookies(cookies goja.Value) AddInitScript(script goja.Value, arg goja.Value) Browser() Browser ClearCookies() ClearPermissions() Close() Cookies() []any // TODO: make it []Cookie later on ExposeBinding(name string, callback goja.Callable, opts goja.Value) ExposeFunction(name string, callback goja.Callable) GrantPermissions(permissions []string, opts goja.Value) NewCDPSession() CDPSession NewPage() Page Pages() []Page Route(url goja.Value, handler goja.Callable) SetDefaultTimeout(timeout int64) SetExtraHTTPHeaders(headers map[string]string) SetGeolocation(geolocation goja.Value) // SetHTTPCredentials sets username/password credentials to use for HTTP authentication. // // Deprecated: Create a new BrowserContext with httpCredentials instead. // See for details: // - https://github.com/microsoft/playwright/issues/2196#issuecomment-627134837 // - https://github.com/microsoft/playwright/pull/2763 SetHTTPCredentials(httpCredentials goja.Value) SetOffline(offline bool) StorageState(opts goja.Value) Unroute(url goja.Value, handler goja.Callable) WaitForEvent(event string, optsOrPredicate goja.Value) any }
BrowserContext is the public interface of a CDP browser context.
type BrowserType ¶
type BrowserType interface { Connect(opts goja.Value) ExecutablePath() string Launch(opts goja.Value) Browser LaunchPersistentContext(userDataDir string, opts goja.Value) Browser Name() string }
BrowserType is the public interface of a CDP browser client.
type CDPSession ¶
CDPSession is the interface of a raw CDP session.
type ElementHandle ¶
type ElementHandle interface { JSHandle BoundingBox() *Rect Check(opts goja.Value) Click(opts goja.Value) error ContentFrame() Frame Dblclick(opts goja.Value) DispatchEvent(typ string, props goja.Value) Fill(value string, opts goja.Value) Focus() GetAttribute(name string) goja.Value Hover(opts goja.Value) InnerHTML() string InnerText() string InputValue(opts goja.Value) string IsChecked() bool IsDisabled() bool IsEditable() bool IsEnabled() bool IsHidden() bool IsVisible() bool OwnerFrame() Frame Press(key string, opts goja.Value) Query(selector string) ElementHandle QueryAll(selector string) []ElementHandle Screenshot(opts goja.Value) goja.ArrayBuffer ScrollIntoViewIfNeeded(opts goja.Value) SelectOption(values goja.Value, opts goja.Value) []string SelectText(opts goja.Value) SetInputFiles(files goja.Value, opts goja.Value) Tap(opts goja.Value) TextContent() string Type(text string, opts goja.Value) Uncheck(opts goja.Value) WaitForElementState(state string, opts goja.Value) WaitForSelector(selector string, opts goja.Value) ElementHandle }
ElementHandle is the interface of an in-page DOM element.
type Frame ¶
type Frame interface { AddScriptTag(opts goja.Value) AddStyleTag(opts goja.Value) Check(selector string, opts goja.Value) ChildFrames() []Frame Click(selector string, opts goja.Value) error Content() string Dblclick(selector string, opts goja.Value) DispatchEvent(selector string, typ string, eventInit goja.Value, opts goja.Value) Evaluate(pageFunc goja.Value, args ...goja.Value) any EvaluateHandle(pageFunc goja.Value, args ...goja.Value) JSHandle Fill(selector string, value string, opts goja.Value) Focus(selector string, opts goja.Value) FrameElement() ElementHandle GetAttribute(selector string, name string, opts goja.Value) goja.Value Goto(url string, opts goja.Value) (Response, error) Hover(selector string, opts goja.Value) InnerHTML(selector string, opts goja.Value) string InnerText(selector string, opts goja.Value) string InputValue(selector string, opts goja.Value) string IsChecked(selector string, opts goja.Value) bool IsDetached() bool IsDisabled(selector string, opts goja.Value) bool IsEditable(selector string, opts goja.Value) bool IsEnabled(selector string, opts goja.Value) bool IsHidden(selector string, opts goja.Value) bool IsVisible(selector string, opts goja.Value) bool ID() string LoaderID() string // Locator creates and returns a new locator for this frame. Locator(selector string, opts goja.Value) Locator Name() string Query(selector string) ElementHandle QueryAll(selector string) []ElementHandle Page() Page ParentFrame() Frame Press(selector string, key string, opts goja.Value) SelectOption(selector string, values goja.Value, opts goja.Value) []string SetContent(html string, opts goja.Value) SetInputFiles(selector string, files goja.Value, opts goja.Value) Tap(selector string, opts goja.Value) TextContent(selector string, opts goja.Value) string Title() string Type(selector string, text string, opts goja.Value) Uncheck(selector string, opts goja.Value) URL() string WaitForFunction(pageFunc, opts goja.Value, args ...goja.Value) (any, error) WaitForLoadState(state string, opts goja.Value) WaitForSelector(selector string, opts goja.Value) ElementHandle WaitForTimeout(timeout int64) }
Frame is the interface of a CDP target frame.
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 JSHandle ¶
type JSHandle interface { AsElement() ElementHandle Dispose() Evaluate(pageFunc goja.Value, args ...goja.Value) any EvaluateHandle(pageFunc goja.Value, args ...goja.Value) JSHandle GetProperties() map[string]JSHandle GetProperty(propertyName string) JSHandle JSONValue() goja.Value ObjectID() cdpruntime.RemoteObjectID }
JSHandle is the interface of an in-page JS object.
type Keyboard ¶
type Keyboard interface { Down(key string) InsertText(char string) Press(key string, opts goja.Value) Type(text string, opts goja.Value) Up(key string) }
Keyboard is the interface of a keyboard input device.
type Locator ¶ added in v0.4.0
type Locator interface { // Click on an element using locator's selector with strict mode on. Click(opts goja.Value) // Dblclick double clicks on an element using locator's selector with strict mode on. Dblclick(opts goja.Value) // Check element using locator's selector with strict mode on. Check(opts goja.Value) // Uncheck element using locator's selector with strict mode on. Uncheck(opts goja.Value) // IsChecked returns true if the element matches the locator's // selector and is checked. Otherwise, returns false. IsChecked(opts goja.Value) bool // IsEditable returns true if the element matches the locator's // selector and is editable. Otherwise, returns false. IsEditable(opts goja.Value) bool // IsEnabled returns true if the element matches the locator's // selector and is enabled. Otherwise, returns false. IsEnabled(opts goja.Value) bool // IsDisabled returns true if the element matches the locator's // selector and is disabled. Otherwise, returns false. IsDisabled(opts goja.Value) bool // IsVisible returns true if the element matches the locator's // selector and is visible. Otherwise, returns false. IsVisible(opts goja.Value) bool // IsHidden returns true if the element matches the locator's // selector and is hidden. Otherwise, returns false. IsHidden(opts goja.Value) bool // Fill out the element using locator's selector with strict mode on. Fill(value string, opts goja.Value) // Focus on the element using locator's selector with strict mode on. Focus(opts goja.Value) // GetAttribute of the element using locator's selector with strict mode on. GetAttribute(name string, opts goja.Value) goja.Value // InnerHTML returns the element's inner HTML that matches // the locator's selector with strict mode on. InnerHTML(opts goja.Value) string // InnerText returns the element's inner text that matches // the locator's selector with strict mode on. InnerText(opts goja.Value) string // TextContent returns the element's text content that matches // the locator's selector with strict mode on. TextContent(opts goja.Value) string // InputValue returns the element's input value that matches // the locator's selector with strict mode on. InputValue(opts goja.Value) string // SelectOption, filters option values of the first element that matches // the locator's selector (with strict mode on), selects the // options, and returns the filtered options. SelectOption(values goja.Value, opts goja.Value) []string // Press the given key on the element found that matches the locator's // selector with strict mode on. Press(key string, opts goja.Value) // Type text on the element found that matches the locator's // selector with strict mode on. Type(text string, opts goja.Value) // Hover moves the pointer over the element that matches the locator's // selector with strict mode on. Hover(opts goja.Value) // Tap the element found that matches the locator's selector with strict mode on. Tap(opts goja.Value) // DispatchEvent dispatches an event for the element matching the // locator's selector with strict mode on. DispatchEvent(typ string, eventInit, opts goja.Value) // WaitFor waits for the element matching the locator's selector // with strict mode on. WaitFor(opts goja.Value) }
Locator represents a way to find element(s) on a page at any moment.
type Mouse ¶
type Mouse interface { Click(x float64, y float64, opts goja.Value) DblClick(x float64, y float64, opts goja.Value) Down(x float64, y float64, opts goja.Value) Move(x float64, y float64, opts goja.Value) Up(x float64, y float64, opts goja.Value) }
Mouse is the interface of a mouse input device.
type Page ¶
type Page interface { AddInitScript(script goja.Value, arg goja.Value) AddScriptTag(opts goja.Value) AddStyleTag(opts goja.Value) BringToFront() Check(selector string, opts goja.Value) Click(selector string, opts goja.Value) error Close(opts goja.Value) Content() string Context() BrowserContext Dblclick(selector string, opts goja.Value) DispatchEvent(selector string, typ string, eventInit goja.Value, opts goja.Value) DragAndDrop(source string, target string, opts goja.Value) EmulateMedia(opts goja.Value) EmulateVisionDeficiency(typ string) Evaluate(pageFunc goja.Value, arg ...goja.Value) any EvaluateHandle(pageFunc goja.Value, arg ...goja.Value) JSHandle ExposeBinding(name string, callback goja.Callable, opts goja.Value) ExposeFunction(name string, callback goja.Callable) Fill(selector string, value string, opts goja.Value) Focus(selector string, opts goja.Value) Frame(frameSelector goja.Value) Frame Frames() []Frame GetAttribute(selector string, name string, opts goja.Value) goja.Value GetKeyboard() Keyboard GetMouse() Mouse GetTouchscreen() Touchscreen GoBack(opts goja.Value) Response GoForward(opts goja.Value) Response Goto(url string, opts goja.Value) (Response, error) Hover(selector string, opts goja.Value) InnerHTML(selector string, opts goja.Value) string InnerText(selector string, opts goja.Value) string InputValue(selector string, opts goja.Value) string IsChecked(selector string, opts goja.Value) bool IsClosed() bool IsDisabled(selector string, opts goja.Value) bool IsEditable(selector string, opts goja.Value) bool IsEnabled(selector string, opts goja.Value) bool IsHidden(selector string, opts goja.Value) bool IsVisible(selector string, opts goja.Value) bool // Locator creates and returns a new locator for this page (main frame). Locator(selector string, opts goja.Value) Locator MainFrame() Frame Opener() Page Pause() Pdf(opts goja.Value) []byte Press(selector string, key string, opts goja.Value) Query(selector string) ElementHandle QueryAll(selector string) []ElementHandle Reload(opts goja.Value) Response Route(url goja.Value, handler goja.Callable) Screenshot(opts goja.Value) goja.ArrayBuffer SelectOption(selector string, values goja.Value, opts goja.Value) []string SetContent(html string, opts goja.Value) SetDefaultTimeout(timeout int64) SetExtraHTTPHeaders(headers map[string]string) SetInputFiles(selector string, files goja.Value, opts goja.Value) SetViewportSize(viewportSize goja.Value) Tap(selector string, opts goja.Value) TextContent(selector string, opts goja.Value) string Title() string Type(selector string, text string, opts goja.Value) Uncheck(selector string, opts goja.Value) Unroute(url goja.Value, handler goja.Callable) URL() string Video() Video ViewportSize() map[string]float64 WaitForEvent(event string, optsOrPredicate goja.Value) any WaitForFunction(fn, opts goja.Value, args ...goja.Value) (any, error) WaitForLoadState(state string, opts goja.Value) WaitForRequest(urlOrPredicate, opts goja.Value) Request WaitForResponse(urlOrPredicate, opts goja.Value) Response WaitForSelector(selector string, opts goja.Value) ElementHandle WaitForTimeout(timeout int64) Workers() []Worker }
Page is the interface of a single browser tab.
type Request ¶
type Request interface { AllHeaders() map[string]string Failure() goja.Value Frame() Frame HeaderValue(string) goja.Value Headers() map[string]string HeadersArray() []HTTPHeader Method() string PostData() string PostDataBuffer() goja.ArrayBuffer PostDataJSON() string RedirectedFrom() Request RedirectedTo() Request ResourceType() string Response() Response Size() HTTPMessageSize Timing() goja.Value URL() string }
Request is the interface of an HTTP request.
type Response ¶
type Response interface { AllHeaders() map[string]string Body() goja.ArrayBuffer Finished() bool Frame() Frame HeaderValue(string) goja.Value HeaderValues(string) []string Headers() map[string]string HeadersArray() []HTTPHeader JSON() goja.Value Ok() bool Request() Request SecurityDetails() goja.Value ServerAddr() goja.Value Size() HTTPMessageSize Status() int64 StatusText() string URL() string }
Response is the interface of an HTTP response.
type Route ¶
type Route interface { Abort(errorCode string) Continue(opts goja.Value) Fulfill(opts goja.Value) Request() Request }
Route is the interface of a route for managing request interception.
type Touchscreen ¶
Touchscreen is the interface of a touchscreen.