The Browser class is the entry point for all your tests, and it is what interacts with the actual web browser via Chrome DevTools Protocol (CDP). It manages:
- BrowserContext which is where you can set a variety of attributes to control the behavior of pages;
- and Page which is where your rendered site is displayed.
A new Browser instance (hence a new browser process) can be created using the launch() method of the chromium module from 'k6/experimental/browser'.
Method | Description |
---|---|
browser.close() | Closes the browser and all of its pages (if any were opened). |
browser.contexts() | Lets you access all open BrowserContexts. |
browser.isConnected | Indicates whether the CDP connection to the browser process is active or not. |
browser.newContext([options]) | Creates and returns a new BrowserContext. |
browser.newPage([options]) | Creates a new Page in a new BrowserContext and returns the page. |
browser.on('disconnected') | Detects the disconnected event from the browser application. |
browser.version() | Returns the browser application's version. |