createBrowser

suspend fun createBrowser(coroutineScope: CoroutineScope, userDataDir: Path? = null, headless: Boolean = false, userAgent: String? = null, browserExecutablePath: Path? = null, browserArgs: List<String>? = null, sandbox: Boolean = true, lang: String? = null, host: String? = null, port: Int? = null): Browser

The entry point for creating a new Browser instance.

This function initializes a new Browser instance with the provided configuration. It sets up the necessary parameters such as user data directory, headless mode, browser executable path, and more. It also handles the creation of a coroutine scope for the browser instance and sets up a shutdown hook to clean up resources when the application exits.

Return

A new instance of the Browser class.

Parameters

coroutineScope

The parent CoroutineScope, in which the browser will run.

userDataDir

Optional path to the user data directory. If not provided, a temporary profile will be created.

headless

If true, the browser will run in headless mode. Defaults to false.

userAgent

Optional user agent string to use for the browser. If not provided, the default user agent will be used.

browserExecutablePath

Optional path to the browser executable. If not provided, the default browser will be used.

browserArgs

Optional list of additional arguments to pass to the browser executable.

sandbox

If true, the browser will run in a sandboxed environment. Defaults to true.

lang

The language to use for the browser.

host

Optional host address for the browser connection. If not provided, defaults to "127.0.0.1".

port

Optional port for the browser connection. If not provided, a free port will be assigned.


suspend fun createBrowser(coroutineScope: CoroutineScope, config: Config): Browser

The entry point for creating a new Browser instance.

This function initializes a new Browser instance with the provided configuration. It sets up the necessary parameters such as user data directory, headless mode, browser executable path, and more. It also handles the creation of a coroutine scope for the browser instance and sets up a shutdown hook to clean up resources when the application exits.

Return

A new instance of the Browser class.

Parameters

coroutineScope

The parent CoroutineScope, in which the browser will run.

config

Configuration for the browser.