new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

browser/methods

13 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Browser.newPage method

Async method: newPage(options?) returns Page. Creates a new page in a new browser context. Closing this page will close the context as well. This is a convenience API intended for single-page scenarios and short snippets; production code and testing frameworks should explicitly create BrowserContext followed by BrowserContext.newPage to control life times. Accepts the same options as newContext including: -inline- (shared context params), proxy, clientCertificates (since v1.46), storageState, storageStatePath (since v1.9). Available since v1.8.

Browser.browserType method

Method signature: browserType() returns BrowserType. Returns the browser type (chromium, firefox or webkit) that the browser belongs to. Available since v1.23.

Browser.close method

Async method: close(reason?: string) returns void. If obtained via BrowserType.launch, closes the browser and all its pages. If connected to a browser server, clears all created contexts and disconnects. The reason parameter (available since v1.40) specifies the reason to be reported to operations interrupted by the browser closure. The Browser object is disposed after closing and cannot be reused. Available since v1.8.

Browser.contexts method

Method signature: contexts() returns Array<BrowserContext>. Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts. Available since v1.8.

Browser.isConnected method

Method signature: isConnected() returns boolean. Indicates that the browser is connected. Available since v1.8.

Browser.newBrowserCDPSession method

Async method: newBrowserCDPSession() returns CDPSession. Returns the newly created browser session. CDP Sessions are only supported on Chromium-based browsers. Available since v1.11.

Browser.newContext method

Async method: newContext(options?) returns BrowserContext. Creates a new browser context that won't share cookies/cache with other browser contexts. Best practice is to explicitly close the returned context via BrowserContext.close when done, before calling Browser.close, to ensure graceful closure and that artifacts like HARs and videos are fully flushed and saved. Accepts options including: -inline- (shared context params), proxy, clientCertificates (since v1.46), storageState, storageStatePath (since v1.9). Available since v1.8.

Browser.bind method

Async method: bind(title: string, options?) returns Object with property endpoint: string. Binds the browser to a named pipe or web socket, making it available for other clients to connect to. Parameters: title (string, required) - Title of the browser server for identification. Options: workspaceDir (string) - Working directory associated with the browser server; metadata (Object<string, any>, JS only) - Additional metadata to associate with the browser server; host (string) - Host to bind the web socket server to; port (int) - Port to bind the web socket server to, use 0 to let OS pick an available port. When host or port specified, a web socket server is created instead of a named pipe. Available since v1.59.

Browser.removeAllListeners method

Async method: removeAllListeners(type?: string, options?) returns void. Removes all the listeners of the given type, or all registered listeners if no type given. Allows to wait for async listeners to complete or to ignore subsequent errors from these listeners. Available in JavaScript only, since v1.47.

Browser.startTracing method

Async method: startTracing(page?: Page, options?) returns void. Controls Chromium Tracing (low-level chromium-specific debugging tool). Creates a trace file that can be opened in Chrome DevTools performance panel. Parameters: page (optional) - if specified, tracing includes screenshots of the given page. Options: path (required, path type) - a path to write the trace file to; screenshots (boolean) - captures screenshots in the trace; categories (Array<string>) - specify custom categories to use instead of default. Available in Java, JavaScript, and Python since v1.11.

Browser.stopTracing method

Async method: stopTracing() returns Buffer. Returns the buffer with trace data. Controls Chromium Tracing (low-level chromium-specific debugging tool). Available in Java, JavaScript, and Python since v1.11.

Browser.unbind method

Async method: unbind() returns void. Unbinds the browser server previously bound with Browser.bind. Available since v1.59.

Browser.version method

Method signature: version() returns string. Returns the browser version. Available since v1.8.

Give your agent this brain