October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Puppeteer Screenshot on GitHub Actions: Install Chrome and Save Artifacts

A practical GitHub Actions recipe for Puppeteer screenshots: install compatible Chrome, save a PNG, upload it as an artifact, and troubleshoot common failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a webpage with Puppeteer in GitHub Actions, install the puppeteer package, let it download its compatible Chrome for Testing browser, save the screenshot to a known path, then upload that file with actions/upload-artifact. If your package manager blocks install scripts, run npx puppeteer browsers install explicitly after installing dependencies.

How to take a Puppeteer screenshot in GitHub Actions

This example uses Node.js 22 and npm. Treat the action and runtime versions as an illustrative pattern: pin versions to your project’s support policy and verify compatibility with your GitHub environment. GitHub’s artifact tutorial uses upload-artifact@v4, while the action repository has later release examples. GitHub’s artifact tutorial and the upload-artifact repository document the current options.

As an Amazon Associate I earn from qualifying purchases.

1. Add a screenshot script

Save this as screenshot.mjs in the repository root. It creates the output directory, opens the target page, writes a full-page PNG, and closes Chrome even if capture fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { mkdir } from 'node:fs/promises';
import puppeteer from 'puppeteer';

await mkdir('artifacts', { recursive: true });
const browser = await puppeteer.launch();

try {
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 900 });
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'artifacts/page.png', fullPage: true });
} finally {
  await browser.close();
}

Page.screenshot() writes to the filesystem when given a path; the Puppeteer guide also covers screenshots of individual elements. Puppeteer screenshot guide

#1 Best Overall
Samsung 14" Galaxy Chromebook Go Laptop PC Computer, Intel Celeron N4500 Processor, 4GB RAM, 64GB Storage, ChromeOS, XE340XDA-KA2US, Student Laptop, Silver
  • SLIM. LIGHTWEIGHT. READY TO GO: The all-new slim design is perfect for busy lives on the go.
  • SKILLFULLY DESIGNED. MILITARY TOUGH: Built with premium craftsmanship to withstand the occasional drop or ding.
  • ALL-DAY, ALL-IN-ONE CHARGING: Power through your school day – and beyond – with a long-lasting 12-hour battery.¹
  • 3X FASTER THAN THE PREVIOUS GENERATION OF WIFI: Crush your schoolwork in record time with Wi-Fi that’s three times faster than the previous generation of Wi-Fi.
  • YOUR PHONE AND CHROMEBOOK WORK BETTER TOGETHER: Easily transfer files between devices, and control your phone right from your Chromebook.

2. Add the workflow

Save as .github/workflows/screenshot.yml. Commit the package manifest and lockfile so npm ci can install the project’s dependencies reproducibly.

name: screenshot
on: [workflow_dispatch]
jobs:
  capture:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      # Keep this explicit if dependency install scripts are blocked.
      - run: npx puppeteer browsers install
      - run: node screenshot.mjs
      - uses: actions/upload-artifact@v4
        with:
          name: page-screenshot
          path: artifacts/page.png
          if-no-files-found: error

The explicit browser-install step is safe to keep when needed, but usually redundant: installing puppeteer normally downloads Chrome for Testing and chrome-headless-shell versions intended to work with that Puppeteer release. If install scripts are permitted and the browser download succeeded, you can omit the explicit step. Puppeteer installation guide

Install Chrome for Puppeteer in CI

Use Puppeteer-managed Chrome for the simplest setup

Install puppeteer rather than puppeteer-core when you want Puppeteer to download and manage its compatible browser. Puppeteer’s browser downloads are substantial: its installation documentation gives approximate Chrome for Testing download sizes of 170 MB on macOS, 282 MB on Linux, and 280 MB on Windows. Those estimates can change with browser versions. Puppeteer installation guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run the browser installer if scripts are blocked

Some package-manager configurations block dependency lifecycle scripts, which can prevent Puppeteer’s normal browser download. Install dependencies, then run npx puppeteer browsers install. Alternatively, configure the package manager to allow Puppeteer’s install script. Use the explicit command when the workflow reports that Chrome is missing.

Rank #2
HP Chromebook 14 Laptop, Intel Celeron N4120, 4 GB RAM, 64 GB eMMC, 14" HD Display, Chrome OS, Thin Design, 4K Graphics, Long Battery Life, Ash Gray Keyboard (14a-na0226nr, 2022, Mineral Silver)
  • FOR HOME, WORK, & SCHOOL – With an Intel processor, 14-inch display, custom-tuned stereo speakers, and long battery life, this Chromebook laptop lets you knock out any assignment or binge-watch your favorite shows..Voltage:5.0 volts
  • HD DISPLAY, PORTABLE DESIGN – See every bit of detail on this micro-edge, anti-glare, 14-inch HD (1366 x 768) display (1); easily take this thin and lightweight laptop PC from room to room, on trips, or in a backpack.
  • ALL-DAY PERFORMANCE – Reliably tackle all your assignments at once with the quad-core, Intel Celeron N4120—the perfect processor for performance, power consumption, and value (2).
  • 4K READY – Smoothly stream 4K content and play your favorite next-gen games with Intel UHD Graphics 600 (3) (4).
  • MEMORY AND STORAGE – Enjoy a boost to your system’s performance with 4 GB of RAM while saving more of your favorite memories with 64 GB of reliable flash-based eMMC storage (5).

Use an externally managed browser only when you need to

puppeteer-core does not download Chrome; it is intended for setups where the browser is managed separately. In that case, provide the executable path when launching Puppeteer and ensure the browser version is compatible with the Puppeteer version. Don’t switch to system Chrome just to fix a missing Puppeteer-managed download unless you specifically need external browser management.

Choose a readiness condition that fits the page

The sample waits for networkidle2, but a navigation wait is not a universal signal that a screenshot is ready. Pages with analytics, polling, streaming, or other continuing requests may not reach network idle reliably. If the page has a stable element that marks the content as ready, wait for that selector instead; for an application, use an appropriate app-specific readiness event. Adjust the wait condition to the page rather than adding a long arbitrary delay.

Save and download the screenshot artifact

The workflow uploads artifacts/page.png as an artifact named page-screenshot. After the run completes, open the workflow run in GitHub Actions and download the artifact from its summary. Artifacts preserve workflow files for later retrieval, including build outputs and debugging files. GitHub artifact tutorial

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the upload path and failure behavior

  • Use the exact path your script writes. Create the parent directory before capturing, as the example does.
  • Use if-no-files-found: error when a screenshot is a required output; without it, a missing file may only produce a warning.
  • Upload a single file for one screenshot, or a directory when the script creates several screenshots.
  • In a matrix workflow, include the operating system or matrix dimension in each artifact name. Artifacts are immutable, so jobs cannot modify the same named artifact.

Set retention deliberately

The upload-artifact repository documentation says artifacts are retained for 90 days by default and describes retention-days values from 1 to 90. Repository, organization, or enterprise policy can impose a shorter limit, so check the policy for the repository rather than assuming a retention period. upload-artifact documentation

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

“Could not find Chrome”

The package manager may have blocked Puppeteer’s install script. Run npx puppeteer browsers install after dependency installation, or allow Puppeteer’s postinstall script. Puppeteer installation guide

Chrome downloaded, but Puppeteer cannot find it

Puppeteer’s default browser cache has been ~/.cache/puppeteer since v19. Check that the install and runtime steps use compatible home and cache paths. To set a stable location explicitly, define PUPPETEER_CACHE_DIR for both installation and execution. Puppeteer configuration

Chrome exists but will not start on Linux

The runner may lack shared libraries or fonts required by the browser. Check Puppeteer’s Linux troubleshooting guidance for common Debian dependencies, and use ldd to identify unresolved shared libraries. The exact packages depend on the runner image. Avoid treating --no-sandbox as a blanket fix: it changes Chrome’s security posture and is not needed for the documented workflow. Puppeteer troubleshooting

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The artifact is missing

Compare the screenshot’s output path with the upload action’s path, confirm the script created the parent directory, and check earlier workflow logs for capture errors. Set if-no-files-found: error to make a missing screenshot fail the job.

Rank #4
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.

Matrix jobs conflict over artifact names

Give each job a distinct artifact name, such as page-screenshot-ubuntu or a name that includes the matrix value. The action’s documentation explains that artifacts are immutable and multiple jobs cannot modify the same named artifact. upload-artifact documentation

Or skip the browser setup

ScreenshotNeo offers a one-request screenshot API if you don’t want to install or maintain a browser in the workflow. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also has an MCP server that lets AI agents take screenshots. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo.

For example, store your API key as a GitHub Actions secret and pass it as an environment variable:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key="$SCREENSHOTNEO_API_KEY" 
  --data-urlencode url=https://example.com 
  -o shot.webp

See the ScreenshotNeo API documentation for options. Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Can I capture a specific element instead of the full page?

Yes. Puppeteer’s screenshot guide documents element screenshots as well as page screenshots; use the element screenshot method for the target element.

Can the workflow run on every push instead of manually?

Yes. Replace the illustrative workflow_dispatch trigger with the events appropriate to your repository, such as a push or pull request trigger.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.