Skip to content

Instantly share code, notes, and snippets.

@jimmont
Created August 6, 2024 12:26

Revisions

  1. jimmont created this gist Aug 6, 2024.
    16 changes: 16 additions & 0 deletions uitest.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // astral alternative to puppeteer and playwright, similar API
    // run: deno run -A ./uitest.js
    // more at https://github.com/lino-levan/astral
    import { launch } from "jsr:@astral/astral";
    const browser = await launch({
    headless: true,
    // note will attempt to auto-install... to use local options use the path value
    // macos
    // path: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
    // debian: sudo apt install chromium-browser chromium-codecs-ffmpeg
    // path: '/usr/lib/chromium-browser/chromium-browser'
    });
    const page = await browser.newPage("https://deno.com");
    const screenshot = await page.screenshot();
    Deno.writeFileSync("screenshot.png", screenshot);
    await browser.close();