module

Playwright::Browser

A Browser is created when Playwright connects to a browser instance, either through browserType.launch([options]) or browserType.connect(params). An example of using a Browser to create a Page:

See ChromiumBrowser, FirefoxBrowser and WebKitBrowser for browser-specific features. Note that browserType.connect(params) and browserType.launch([options]) always return a specific browser instance, based on the browser being connected to or launched.

Instance methods

add_listener(type : EventType, listener : Listener(EventType))
Source
close

In case this browser is obtained using browserType.launch([options]), closes the browser and all of its pages (if any were opened). In case this browser is obtained using browserType.connect(params), clears all created contexts belonging to this browser and disconnects from the browser server. The Browser object itself is considered to be disposed and cannot be used anymore.

Source
contexts

Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.

Source
is_connected

Indicates that the browser is connected.

Source
new_context(options : NewContextOptions | Nil) : BrowserContext

Creates a new browser context. It won't share cookies/cache with other browser contexts.

Source
new_context
Source
new_page(options : NewPageOptions | Nil) : Page

Creates a new page in a new browser context. Closing this page will close the context as well. This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and testing frameworks should explicitly create browser.newContext([options]) followed by the browserContext.newPage() to control their exact life times.

Source
new_page
Source
remove_listener(type : EventType, listener : Listener(EventType))
Source
version

Returns the browser version.

Source

Nested types