Newer
Older
bugtrail / packages / extension / verify-popup-shot.mjs
import { chromium } from "playwright-core";
import { join, dirname } from "node:path";
import { homedir } from "node:os";
const root = "/home/gmikcon/Projects/live-testing-tool/packages/extension";
const exe = join(homedir(), ".cache/ms-playwright/chromium-1234/chrome-linux64/chrome");
const context = await chromium.launchPersistentContext("", {
  executablePath: exe, headless: true,
  args: [`--disable-extensions-except=${root}/dist/chrome`, `--load-extension=${root}/dist/chrome`],
});
let [worker] = context.serviceWorkers();
if (!worker) worker = await context.waitForEvent("serviceworker", { timeout: 10000 });
const id = new URL(worker.url()).host;
const popup = await context.newPage();
await popup.goto(`chrome-extension://${id}/src/popup/popup.html`);
await popup.waitForSelector(".popup-head", { timeout: 10000 });
await popup.waitForTimeout(600);
await popup.screenshot({ path: "/tmp/ltt-shots/29-popup-logo.png" });
await context.close();