module Playwright::Browser

Overview

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.

Defined in:

playwright/browser.cr

Instance Method Summary

Instance Method Detail

abstract def add_listener(type : EventType, listener : Listener(EventType)) #

[View source]
abstract def close : Nil #

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.


[View source]
abstract def contexts : Array(BrowserContext) #

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


[View source]
abstract def is_connected : Bool #

Indicates that the browser is connected.


[View source]
abstract def new_context(options : NewContextOptions?) : BrowserContext #

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


[View source]
def new_context : BrowserContext #

[View source]
abstract def new_page(options : NewPageOptions?) : 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.


[View source]
def new_page : Page #

[View source]
abstract def remove_listener(type : EventType, listener : Listener(EventType)) #

[View source]
abstract def version : String #

Returns the browser version.


[View source]