Skip to content

Instantly share code, notes, and snippets.

@potatoqualitee
Last active August 27, 2022 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potatoqualitee/b161cf32a491ae0db27bfa3c4fad993b to your computer and use it in GitHub Desktop.
Save potatoqualitee/b161cf32a491ae0db27bfa3c4fad993b to your computer and use it in GitHub Desktop.
Download file using Playwright in GitHub Actions
on: push
jobs:
download-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install playwright
run: |
npx --yes playwright install --with-deps chromium
npm install -D @playwright/test
npm install playwright
- name: Execute json downloader
run: |
node ./tests/download.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true, downloadsPath: '' });
const page = await browser.newPage({ acceptDownloads: true });
await page.goto('https://windowsterminalthemes.dev/');
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('text=Download .json of themes').click()
]);
await download.saveAs(download.suggestedFilename());
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment