Last active
August 27, 2022 01:15
-
-
Save potatoqualitee/b161cf32a491ae0db27bfa3c4fad993b to your computer and use it in GitHub Desktop.
Download file using Playwright in GitHub Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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