The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Use Selenium’s Chrome driver with Chrome’s --headless option, save the current browser window to a PNG in your workspace, then upload that directory as a GitHub Actions artifact. The workflow below also uploads screenshots when a test fails, so you can inspect them after the job ends.
What the workflow does
A hosted runner has no visible desktop to interact with, but Chrome can run in headless mode. Selenium can capture the current browser window to a file; GitHub Actions artifacts preserve that file after the job finishes.
- Install the project’s Selenium and test dependencies.
- Start Chrome with
--headless, set a deliberate viewport, and wait for the page state you need. - Save the screenshot under a known directory such as
artifacts/. - Upload that directory with
actions/upload-artifact, configured to run even if the test step fails. - Close the WebDriver in a
finallyblock so the browser is shut down on errors as well as success.
Capture a screenshot with Selenium in Python
This runnable example writes the current browser window to artifacts/page.png. The 1440×1000 viewport is an example choice, not a GitHub Actions or Selenium requirement.
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
output = Path("artifacts")
output.mkdir(parents=True, exist_ok=True)
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
try:
driver.set_window_size(1440, 1000)
driver.get("https://example.com")
saved = driver.save_screenshot(str(output / "page.png"))
if not saved:
raise OSError("Selenium could not write the screenshot")
finally:
driver.quit()
Selenium’s TakeScreenshot documentation describes this as capturing the current browsing context. In Python, save_screenshot(path) writes a PNG and returns False if an I/O error prevents writing, so checking the return value can make a missing file fail the test clearly.
#1 Best Overall
Wait for the state you intend to capture
A successful screenshot call does not mean the application has finished rendering. If the page loads data asynchronously, wait for a stable signal—typically a target element becoming visible—before calling save_screenshot. Keep that wait tied to the application state your test is meant to verify rather than adding an arbitrary delay by default.
Choose the capture target deliberately
The basic call captures the current browser window, not necessarily the entire height of a long page. Selenium also supports capturing a particular element; use that when the evidence should focus on one component, and choose a selector stable enough to survive ordinary page changes. Set the window size before navigation when consistent viewport dimensions matter. See Selenium’s screenshot guide for binding-specific examples.
Upload screenshots from GitHub Actions
Put the test step before the artifact upload step and use the same directory in both places. The if: always() condition lets the upload step run after a failing test step, which is useful when failure hooks create diagnostic screenshots. It cannot upload a file that was never created.
name: Selenium tests
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: python -m pip install selenium
- name: Run Selenium test
run: python test_screenshot.py
- name: Upload screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: selenium-screenshots
path: artifacts/
This example pins action major versions as shown; check the actions’ current official documentation and your repository’s policy before adopting or changing versions. GitHub describes artifacts as a way to retain and share files produced by a workflow, and lists screenshots among common artifacts: Workflow artifacts.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsCapture on test failure
If screenshots are only useful for diagnosing failures, put the screenshot call in your test framework’s failure hook or teardown and still upload artifacts/ with if: always(). Ensure the directory exists before saving. A screenshot taken during teardown can only show the state Selenium still has access to; if setup failed before Chrome started or the target page loaded, there may be no meaningful image to preserve.
Runner and browser version considerations
GitHub-hosted runner images include browser automation software, but installed versions change as the images are updated. The Ubuntu 24.04 runner image README’s inventory reviewed on 2026-10-03 listed Google Chrome 153.0.8010.52, ChromeDriver 153.0.8010.52, Chromium 153.0.8010.0, and Selenium server 4.49.0. Treat these as an inventory snapshot, not a promise about later runs: see the Ubuntu 24.04 runner image README.
Rank #4
The runner-images project currently identifies ubuntu-latest as an alias for Ubuntu 24.04 and notes that the -latest label follows the latest generally available image over time. Select an explicit OS label when that fits your reproducibility needs, and inspect the job setup log to see the image and installed software actually used. Consult the GitHub Actions Runner Images project for current labels and image details.
Selenium bindings use Selenium Manager by default for automated browser and driver management. On a hosted runner that already has browser and driver binaries, diagnose the versions and paths resolved in the actual job rather than assuming that installation or PATH behavior matches another image. Selenium’s Selenium Manager documentation explains its role.
Recommended Free Tools
Best Value
Common failures and fixes
| Symptom | Likely cause | What to check or change |
|---|---|---|
| No screenshot appears in the artifact | The test failed before writing the file, the output directory was missing, or the upload path does not match the code. | Create the directory before capture, check the screenshot method’s return value, and use the same path in the test and artifact step. Confirm the upload step ran. |
| The upload step reports that no files were found | The configured artifact path is wrong or no image was produced. | Check the test’s output path and runner logs. Remember that if: always() runs the upload step; it does not create missing files. |
| Chrome or ChromeDriver fails to start | The resolved browser and driver are unavailable or mismatched, or startup configuration differs from expectations. | Inspect the runner setup log for the selected image and actual browser/driver versions and paths. Check whether the runner provides binaries and how Selenium Manager resolves them. |
| The PNG shows a loading state or incomplete page | The screenshot was taken before the application reached the intended state. | Wait for a specific element or other meaningful readiness condition before capture. |
| The image dimensions vary between runs | The browser window size was not set consistently before capture. | Set a deliberate window size before navigation, then keep the value consistent across test runs. |
| The screenshot omits content below the visible window | The basic WebDriver screenshot captures the current window, not a guaranteed full-page image. | Decide whether the test needs visible-window evidence or a specific element screenshot; do not assume the basic call captures the whole document. |
Reliability, performance, and artifact safety
- Use a clear readiness condition before capture; an immediate screenshot may be fast but misleading when the page is still rendering.
- Always close the driver, including when navigation or capture raises an exception.
- Keep screenshots in a predictable workspace path and upload only the files needed for debugging. GitHub-hosted runners are temporary environments, so a local file alone is not a durable record after the job ends.
- Screenshots can expose account details, customer data, tokens rendered on the page, or other sensitive information. Review the page content and artifact access policy before uploading them.
- For repeatable CI behavior, record the selected runner image and resolved browser/driver versions in logs, and revisit the OS label as GitHub updates supported images.
Or skip the browser setup
If you need a screenshot of a public page rather than a Selenium-driven test, ScreenshotNeo offers a one-request screenshot API. It accepts one GET request for a URL and returns PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to try up to 1,000 screenshots a month without a card.
Frequently Asked Questions
Does Selenium’s basic screenshot call capture a full webpage?
No. The standard WebDriver call captures the current browser window; it does not promise a full-page image.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Can I keep screenshots if a GitHub Actions test fails?
Yes, if the test writes the files and the later artifact upload step is configured to run after failure.
Will every Ubuntu runner use the same Chrome and ChromeDriver versions?
No. Hosted runner software changes with image updates, so check the setup log for the versions used by a particular run.
Quick Recap
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.




