Important
You need to install weston
in your Linux:
- Debian/Ubuntu:
sudo apt-get install weston - Arch:
sudo pacman -S weston
Start an instance of weston (a Wayland compositor) and launches the browser in
this virtual framebuffer. This plugin is only useful in headful mode.
This plugin supports the following option:
args(default["--width", "1920", "--height", "1080"]): Arguments passed to the executableweston.keepalive(defaultfalse): Keep thewestoninstance alive after the browser is closed. If this option is enabled, it is advisable to also provide asignalto stop thewestonexecutable manually.signal: Signal to stop thewestoninstance. Works in the same way as thesignalparameter offetch().
Use the plugin with default options.
import { chromium } from "playwright-ghost";
import toolsWestonPlugin from "playwright-ghost/plugins/tools/weston";
const browser = await chromium.launch({
headless: false,
plugins: [toolsWestonPlugin()],
});
// ...Use the plugin and specify arguments for a 2K screen.
import { chromium } from "playwright-ghost";
import toolsWestonPlugin from "playwright-ghost/plugins/tools/weston";
const browser = await chromium.launch({
headless: false,
plugins: [
toolsWestonPlugin({ args: ["--width", "2560", "--height", "1440"] }),
],
});
// ...Use the plugin with keepalive and signal.
import { chromium } from "playwright-ghost";
import toolsWestonPlugin from "playwright-ghost/plugins/tools/weston";
const controller = new AbortController();
// Launch a browser and start weston.
const browser = await chromium.launch({
headless: false,
plugins: [toolsWestonPlugin({ keepalive: true, signal: controller.signal })],
});
// ...
// Close the browser, but don't stop weston.
browser.close();
// Launch an other browser and reuse weston.
const otherBrowser = await chromium.launch({
headless: false,
plugins: [toolsWestonPlugin({ keepalive: true, signal: controller.signal })],
});
// ...
// Close the other browser, but don't stop weston.
otherBrowser.close();
// Stop weston.
controller.abort();