Skip to main content

BrowserServer


方法

🌐 Methods

close

Added before v1.9 browserServer.close

正常关闭浏览器并确保进程终止。

🌐 Closes the browser gracefully and makes sure the process is terminated.

用法

await browserServer.close();

返回


kill

Added before v1.9 browserServer.kill

终止浏览器进程并等待该进程退出。

🌐 Kills the browser process and waits for the process to exit.

用法

await browserServer.kill();

返回


process

Added before v1.9 browserServer.process

生成浏览器应用进程。

🌐 Spawned browser application process.

用法

browserServer.process();

返回


wsEndpoint

Added before v1.9 browserServer.wsEndpoint

浏览器 websocket url。

🌐 Browser websocket url.

浏览器 WebSocket 端点,可用作 browserType.connect() 的参数,以建立与浏览器的连接。

🌐 Browser websocket endpoint which can be used as an argument to browserType.connect() to establish connection to the browser.

请注意,如果在 launchServer 选项中没有指定监听 host 选项,即使实际监听地址是未指定地址,本地主机地址仍然会被输出。

🌐 Note that if the listen host option in launchServer options is not specified, localhost will be output anyway, even if the actual listening address is an unspecified address.

用法

browserServer.wsEndpoint();

返回


事件

🌐 Events

on('close')

Added before v1.9 browserServer.on('close')

当浏览器服务器关闭时触发。

🌐 Emitted when the browser server closes.

用法

browserServer.on('close', data => {});