ScreenshotNeo

BlogComparisons

ScreenshotMachine CLI vs Selenium Screenshots: Which Is Easier to Automate?

Use ScreenshotMachine’s curl API for unattended URL captures; use Selenium when a screenshot depends on browser interaction. Compare setup, code, limits, and errors.

By the ScreenshotNeo team4 October 202611 min read

Short answer: For unattended screenshots of known URLs from a shell script, ScreenshotMachine’s hosted HTTP API is usually easier to automate: call it with curl, a customer key, and capture parameters, then save the response. It is a curl-based API workflow; the reviewed documentation does not establish a separate standalone ScreenshotMachine CLI executable. Selenium is easier when the screenshot is one step in a browser automation flow that must navigate, interact with controls, wait for state, or capture a particular element.

Neither is universally easier. Choose based on whether you need a screenshot service or control over a browser session. This guide compares the documented approaches and shows runnable starting points. It does not claim a head-to-head benchmark.

1. What “ScreenshotMachine CLI” means

ScreenshotMachine documents an HTTP GET screenshot API and a shell example using curl. You can put that request in a shell script or CI job, but the documentation reviewed here does not establish a separately installed command-line executable. The request needs a ScreenshotMachine customer key and network access to its hosted API. See the ScreenshotMachine API documentation.

Selenium is a browser automation framework. A WebDriver binding starts or connects to a browser session, navigates to a page, and can take a screenshot of the current context or a located element. The screenshot is part of that session rather than a separate hosted screenshot request. See Selenium’s WebDriver browser documentation.

2. Choose by the work surrounding the screenshot

Need Better starting point Reason
Capture a known URL from a cron job or shell script ScreenshotMachine API with curl One HTTP request can return the capture file. You need a key, network access, and a suitable API option.
Navigate, click, enter data, or verify browser state before capture Selenium Navigation and browser interaction happen in the same WebDriver session.
Capture a single DOM element Either ScreenshotMachine documents an element selector parameter; Selenium can locate an element and invoke its screenshot method.
Run a browser test and attach an image when it fails Selenium The screenshot can be taken from the browser session already used by the test.
Keep browser installation and session management out of a small script ScreenshotMachine API The browser runs behind the hosted service, while the script makes an HTTP request.
Control a workflow not represented by the API’s documented parameters Selenium Use browser actions directly, provided the page and environment can be automated.

ScreenshotMachine documents options for dimensions, full-page dimensions, device presets, output format, delay, cache controls, cookies, click and hide selectors, element selection, and cropping. Check its current API parameter documentation to confirm that a particular action is supported before choosing it over browser automation.

3. ScreenshotMachine from a shell script

For a simple capture, make a GET request with the URL and customer key, then write the response bytes to a file. The exact parameter names and supported values should be taken from ScreenshotMachine’s current documentation. The example below shows the documented curl-style pattern; set the key through an environment variable so it is not committed to source control.

#!/usr/bin/env bash
set -euo pipefail

: "${SCREENSHOTMACHINE_CUSTOMER_KEY:?Set SCREENSHOTMACHINE_CUSTOMER_KEY first}"

curl --fail --silent --show-error --get \
  "https://api.screenshotmachine.com" \
  --data-urlencode "customer=${SCREENSHOTMACHINE_CUSTOMER_KEY}" \
  --data-urlencode "url=https://example.com" \
  --output screenshot.png

Use the endpoint, parameter names, and output settings prescribed by the vendor account and current API documentation; the dossier establishes the curl/API workflow, but not a universal endpoint or exact parameter schema for all accounts. Avoid printing the key in shell tracing or CI logs. In production, check the HTTP status and validate that the output is a usable image rather than assuming every response is a screenshot.

Useful documented capture controls include width and height, full-page dimensions, device presets, JPG/PNG/GIF output, delay, cache behavior, cookies, click and hide selectors, an element selector, and crop options. Consult the API docs for exact parameter names and constraints. Use a delay only where a known render delay is needed; it does not prove that a dynamic page has reached the desired state.

4. Selenium screenshot in Python

This Python example uses Selenium 4 with Chrome and saves a screenshot of the current browser viewport. Install Selenium and have a compatible Chrome browser available in the execution environment. Selenium Manager can help manage drivers in supported setups; browser and driver availability still depend on the environment.

from pathlib import Path
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_argument("--window-size=1440,1000")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    WebDriverWait(driver, 20).until(
        lambda d: d.execute_script("return document.readyState") == "complete"
    )
    Path("screenshot.png").write_bytes(driver.get_screenshot_as_png())
finally:
    driver.quit()

document.readyState == complete is a basic navigation condition, not a guarantee that client-side data, animations, or lazy-loaded images are ready. If the page has a known readiness signal, wait for that specific element or state instead. For example:

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main .report-ready"))
)

5. Selenium element and full-page considerations

To save a specific element, locate it after navigation and call its screenshot method:

from selenium.webdriver.common.by import By

element = driver.find_element(By.CSS_SELECTOR, "main article")
element.screenshot("article.png")

Element screenshots can fail when the element is absent, hidden, outside the renderable state, or covered by an overlay. Wait for it to be visible and scroll it into view if needed. Browser screenshot behavior and full-page capture support vary by browser and driver; a viewport screenshot should not be described as a full-page capture. If you require a full document image, use a browser-specific supported capability or capture the page in controlled scroll segments, then verify the resulting dimensions and joins.

For a click before capture, make the desired browser action explicit:

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

button = WebDriverWait(driver, 20).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "button.accept"))
)
button.click()

Use this only when interacting with the page is part of the intended workflow, such as dismissing a consent prompt in a test. Avoid clicking controls based on fragile page text or selectors when a stable test identifier is available.

6. cURL, Python, and Node.js comparison

ScreenshotMachine via cURL

The shell example above is the smallest pattern for scheduled URL captures. Keep credentials outside the command text where possible and follow the API’s current parameter names.

ScreenshotMachine via Python

import os
import requests

key = os.environ["SCREENSHOTMACHINE_CUSTOMER_KEY"]
response = requests.get(
    "https://api.screenshotmachine.com",
    params={"customer": key, "url": "https://example.com"},
    timeout=90,
)
response.raise_for_status()
with open("screenshot.png", "wb") as image_file:
    image_file.write(response.content)

Confirm the endpoint and parameter names for your account in the official docs. Add response content-type or image decoding validation if downstream code requires a valid image.

ScreenshotMachine via Node.js

const key = process.env.SCREENSHOTMACHINE_CUSTOMER_KEY;
if (!key) throw new Error("Set SCREENSHOTMACHINE_CUSTOMER_KEY");

const params = new URLSearchParams({
  customer: key,
  url: "https://example.com",
});
const response = await fetch(`https://api.screenshotmachine.com?${params}`, {
  signal: AbortSignal.timeout(90_000),
});
if (!response.ok) {
  throw new Error(`Screenshot request failed: HTTP ${response.status}`);
}
const image = Buffer.from(await response.arrayBuffer());
const { writeFile } = await import("node:fs/promises");
await writeFile("screenshot.png", image);

Node.js must provide global fetch and AbortSignal.timeout for this exact snippet; on older runtimes, use a supported HTTP client and timeout mechanism. As with the other examples, verify current API parameters before use.

7. Automation details that affect the choice

Authentication and secrets

The ScreenshotMachine hosted API requires a customer key. Store it in a secret manager or CI secret and pass it at runtime. Do not place credentials in a public URL, checked-in script, screenshot filename, or logs. Selenium usually needs no screenshot-service key, though the target site may require test credentials or authenticated browser state.

Waiting for the right page state

A fixed delay is simple but can waste time on fast pages and still be too short on slow ones. Selenium can wait on a specific DOM condition within the browser session. ScreenshotMachine documents a delay option; for application-specific readiness, verify that the API offers a suitable mechanism before relying on it.

Viewport, output, and dimensions

Set dimensions deliberately. A viewport-sized capture and a full-page image serve different purposes; large full-page captures can produce much larger files. ScreenshotMachine documents dimensions, device presets, full-page dimensions, format and crop controls. In Selenium, set the browser window size before navigation or capture and check actual output dimensions, especially in headless runs.

Dynamic pages and lazy content

Pages that load data after navigation, animate, or defer images need an explicit readiness condition or supported wait strategy. A generic page-load completion signal may occur before application content is ready. For Selenium, wait for a stable element or state. For an API service, use documented wait or delay controls and confirm their behavior for the target page.

Concurrency and repeatability

Parallel Selenium runs each need a browser session and enough memory and CPU; limit concurrency to what the worker can sustain. Hosted API calls avoid local browser processes, but depend on the service and network and remain subject to the account’s quota and plan. Use bounded retries for transient failures, with backoff, and avoid retrying invalid URLs or authentication errors unchanged.

8. Reliability, performance, and cost

There is no comparative timing data in the cited research, so the choice should not be based on a claimed speed winner. A curl request avoids managing a local browser process, but depends on network access and the hosted API. Selenium gives direct browser control but requires a working browser/driver environment and consumes worker resources.

ScreenshotMachine lists monthly capture plans. The pricing snapshot reviewed on October 3, 2026 lists Starter as free for 100 fresh screenshots/month, Basic at €9/month for 2,500, Pro at €59/month for 20,000, and Enterprise at €99/month for 50,000. These are vendor-published figures, not a performance comparison; verify current prices, quotas, and what counts as a fresh screenshot on the pricing page before budgeting.

The cited Selenium documentation describes software capability, not a hosted screenshot quota or service price. Your Selenium cost depends on where you run browsers and maintain the execution environment. Include compute, browser updates, debugging time, and parallel capacity when comparing total operating effort.

9. Common errors and fixes

Symptom Likely cause Fix
ScreenshotMachine request is unauthorized or rejected Missing, invalid, or incorrectly passed customer key; parameter mismatch Check the account key and current API parameter names. Keep the credential out of logs.
Saved file is empty or not an image HTTP error response, API error body, or a failed capture saved as though it were image bytes Check HTTP status, inspect content type and error body safely, and validate image decoding before using the file.
Request times out Slow target page, network problem, or timeout too short for a render Set a realistic request timeout, bound retries with backoff, and investigate whether the target URL loads from the capture environment.
Selenium cannot start Chrome Browser missing, incompatible environment, or browser/driver startup issue Install a supported browser, use a compatible Selenium setup, and inspect startup logs in the worker environment.
Selenium screenshot is blank or stale Capture happened before app content rendered, or the browser is on an unexpected page Assert the final URL and wait for a page-specific visible element before capture.
Element screenshot lookup fails Selector changed, element is not present yet, or the wrong frame/shadow context is active Check the selector, wait for presence/visibility, and switch to the required frame or supported shadow-root context.
Only part of a long page appears A viewport screenshot was used where full-page output was expected Use a documented full-page option or a browser-specific full-page mechanism, then validate dimensions.
Intermittent CI failures Resource contention, race conditions, flaky target page, or unbounded parallelism Limit concurrency, wait on explicit conditions, capture diagnostic logs, and retry only transient failures.

10. Recommendation

Use ScreenshotMachine’s curl/API route when the job is “capture this URL with these options” and a hosted service and customer key fit your environment. Use Selenium when the job is “drive this browser through these steps, then capture what it shows.” For an existing Selenium test suite, adding a screenshot to the same session is often the more direct automation path. For a shell pipeline of known URLs, a single API request is usually the smaller setup.

If you are choosing a hosted screenshot API, ScreenshotNeo is the first alternative to try: it removes consent banners, newsletter popups, and chat widgets before capture, and bills only clean shots.

11. Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF; its API documentation describes the available parameters.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. The MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month, with no card.

12. FAQ

Can I run ScreenshotMachine from a shell script?

Yes. Its documented workflow includes calling the hosted HTTP API with curl. That is a shell-scriptable API route; the cited documentation does not establish a separate standalone CLI program.

How do I take a screenshot with Selenium?

Start a WebDriver session, navigate with get(), wait for the page state you need, then call the driver screenshot method. Locate an element first if you need an element screenshot.

Do I need Selenium if all I need is a URL screenshot?

No. A hosted screenshot API can be simpler for unattended URL captures. Selenium is useful when the browser must perform steps that the API’s available options do not cover.

Which one is cheaper?

It depends on volume and operating costs. ScreenshotMachine publishes service quotas and prices; Selenium itself is not presented in the cited documentation as a hosted screenshot plan, so account for the infrastructure and maintenance needed to run browsers.