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.

If capture() saves an image but captureSelector() reports “Failed to save screenshot to …; please check permissions,” the file system may not be the real problem. The selector may match nothing, the element may have zero size, the page may still be navigating, or the output filename may imply an unsupported format. Fix the failure by waiting for the target, capturing after navigation settles, using an absolute writable path, checking the selector in page context, and testing html or body as a diagnostic.

What captureSelector actually requires

captureSelector(targetFile, selector, imgOptions) asks CasperJS to render the page region represented by a CSS selector and write that rendering to targetFile. The selector must match a real, renderable element at the instant of capture. A successful full-page capture() does not prove that the selector route can derive a valid rectangle.

PhantomJS performs the final render. It normally infers the image format from the filename extension; PNG, JPEG, PDF, BMP and PPM are supported, while GIF support depends on the PhantomJS build. The destination directory must already exist and the PhantomJS process must be able to write to it.

Use a readiness-gated capture

Do not capture immediately after start(), a click, or form submission. Put the operation in a later CasperJS step and wait for the element that proves the page is ready.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
var casper = require('casper').create();
var url = 'https://example.com/dashboard';
var output = '/var/tmp/casper-shots/dashboard.png';

casper.start(url);

casper.waitForSelector('#dashboard', function () {
    this.viewport(1280, 900);
    this.captureSelector(output, '#dashboard', {
        format: 'png'
    });
    this.echo('Saved ' + output);
}, function () {
    this.die('Target selector did not appear: #dashboard');
}, 10000);

casper.run();

The success callback runs only after #dashboard is found. The failure callback exits after 10 seconds instead of attempting to render an absent element. Adjust the timeout for a known slow application, but avoid an indefinite wait that hides a broken page.

Confirm the selector and its geometry

In the page context, check both existence and dimensions before rendering:

casper.waitForSelector('#dashboard', function () {
    var info = this.evaluate(function () {
        var el = document.querySelector('#dashboard');
        if (!el) return { exists: false };
        var r = el.getBoundingClientRect();
        var style = window.getComputedStyle(el);
        return {
            exists: true,
            width: r.width,
            height: r.height,
            display: style.display,
            visibility: style.visibility
        };
    });
    this.echo(JSON.stringify(info));
    if (!info.exists || info.width === 0 || info.height === 0) {
        this.die('Selector exists but has no renderable area');
    }
    this.captureSelector('/var/tmp/casper-shots/dashboard.png', '#dashboard', {
        format: 'png'
    });
});

A selector can exist in the DOM while being hidden, collapsed, replaced by a framework render, or located outside the visible layout. A non-zero bounding rectangle is a useful check, not a guarantee that every descendant has finished loading.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Check the output path, extension and process permissions

  1. Create the directory first. PhantomJS will not reliably create a missing parent directory. Create /var/tmp/casper-shots (or your chosen directory) before running CasperJS.
  2. Prefer an absolute path. A relative path is resolved from the process working directory, which may differ when a scheduler, service, Docker container or CI runner launches the script.
  3. Test the actual runtime user. The account running PhantomJS, not your interactive login, needs write and execute permission on every directory in the path. Check ownership and permissions under that account.
  4. Match extension and format. Use .png, .jpg/.jpeg, .pdf, .bmp or .ppm, or pass an explicit format such as 'png'. Do not save PNG data with a misleading extension.
  5. Check disk and sandbox limits. A full disk, read-only container volume, restrictive temporary directory or security policy can produce the same generic save message.

The “please check permissions” wording is therefore not conclusive proof of a Unix or Windows permission failure. Filename validity, format selection and page renderability are also part of the documented rendering path.

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

Use html and body as diagnostic controls

Try a broad selector after the narrow selector fails:

casper.wait(1000, function () {
    this.captureSelector('/var/tmp/casper-shots/html.png', 'html', {format: 'png'});
    this.captureSelector('/var/tmp/casper-shots/body.png', 'body', {format: 'png'});
});

Reports of html or body succeeding while a component selector fails usually point to selector geometry or page state rather than only filesystem access. This is a diagnostic, not a universal workaround. If the broad capture works, investigate:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  • Whether the selector is misspelled, duplicated or generated only after a later request.
  • Whether the element has zero width or height, display:none, or visibility:hidden.
  • Whether a parent clips it, an animation is replacing it, or a virtualized list has not mounted it.
  • Whether the target is inside an iframe. A selector in the top document cannot directly select an element inside a frame; switch to the frame context or capture the frame page separately.

Separate selector capture from fixed-rectangle capture

captureSelector() derives a rectangle from a DOM element. capture() can render the whole page or a known rectangle supplied with clipRect. The latter is useful when the layout is stable but selector-derived geometry is unreliable.

casper.start('https://example.com/report');
casper.then(function () {
    this.viewport(1280, 900);
    this.capture('/var/tmp/casper-shots/report-region.png', {
        format: 'png',
        clipRect: { top: 120, left: 80, width: 900, height: 600 }
    });
});
casper.run();

Without clipRect, PhantomJS renders the whole page. Use captureSelector when the DOM element is the source of truth; use clipRect when you intentionally want fixed screen coordinates. A viewport controls responsive layout, while clipRect controls the rasterized rectangle. Set the viewport before waiting and capturing so media queries and element dimensions are deterministic.

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

Handle redirects, submissions and asynchronous pages

Navigation and form submission can leave CasperJS in a transient document. A capture placed in the same step as a submit may run before the redirect or application render completes. Put it in a subsequent step and wait for a destination marker.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
casper.start('https://example.com/login');
casper.then(function () {
    this.fillSelectors('form', {
        'input[name="user"]': 'demo',
        'input[name="password"]': 'secret'
    }, true);
});
casper.then(function () {
    this.waitForSelector('#account-home', function () {
        this.captureSelector('/var/tmp/casper-shots/account.png', '#account-home', {
            format: 'png'
        });
    }, function () {
        this.die('Login destination did not load');
    }, 15000);
});
casper.run();

For pages whose important content arrives after the initial DOM, wait for a content-specific selector rather than relying only on a fixed sleep. A short delay can supplement a selector wait for animations, but it should not replace a readiness condition.

A repeatable troubleshooting sequence

  1. Log the URL, current page URL and the exact selector immediately before capture.
  2. Replace the output with an absolute path in a directory created for the test.
  3. Run the script under the same user and environment as production; verify directory write access and available disk space.
  4. Use a conventional extension and explicit format.
  5. Call waitForSelector() and inspect existence, dimensions, display and visibility with evaluate().
  6. Set viewportSize (or this.viewport()) before the capture.
  7. Try html, then body. If those work, focus on selector validity, geometry, frames and replacement during navigation.
  8. If a submit or redirect occurred, move capture to a later CasperJS step and wait for a destination selector.
  9. Try capture() with a measured clipRect to distinguish DOM-selection problems from rendering or file-output problems.
  10. Record CasperJS and PhantomJS versions and reduce the case to a minimal page. Legacy engines may fail on modern JavaScript, TLS, CSS or browser APIs even when the same URL works in a current browser.

Common symptoms, causes and fixes

Symptom Likely cause Fix
capture() works; a component selector fails Selector does not match, has zero geometry, is hidden, framed or replaced Wait for it, inspect dimensions, test html/body, and check iframe context
Every target fails with a save error Missing directory, wrong working directory, unwritable runtime user, full or read-only volume Use an existing absolute directory and verify access as the PhantomJS user
Files are created but cannot be opened Extension/format mismatch or unsupported format in that PhantomJS build Use PNG or JPEG with a matching extension and explicit format
Capture is blank or partial after login Redirect, asynchronous render or animation is still in progress Capture in a later step after a destination selector appears; allow required assets to load
Only modern sites fail PhantomJS’s old browser engine lacks current web-platform behavior Reproduce minimally, then plan migration to maintained browser automation
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reliability and long-term migration

CasperJS is no longer actively maintained, and PhantomJS development is suspended. You can make an existing job more reliable with explicit waits, deterministic viewports, absolute paths and narrow test pages, but those changes do not add modern browser compatibility. If the target site depends on current TLS, JavaScript syntax, CSS layout, web fonts or browser APIs, migrate the workflow to a maintained automation tool and keep the CasperJS script only as a short-term compatibility path.

When migrating, preserve the same diagnostic distinctions: wait for a meaningful readiness condition, capture a DOM element when you need semantic region selection, use a fixed clip when coordinates are intentional, and record the browser’s final URL and page errors. Do not assume that changing automation libraries will correct a missing selector or unwritable destination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

For a direct URL-to-image or PDF workflow, ScreenshotNeo provides a screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

One request is enough:

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}`);

See the parameter reference and options in the ScreenshotNeo documentation. The service supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, selector waits, delays or network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk calls for up to 100 URLs, a usage API and an OpenAPI specification. Common parameter names used by other screenshot APIs also work.

An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients, so an AI agent can perform the capture without custom PhantomJS code. Pricing is Free for 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots, with yearly billing providing two months free. Create a free ScreenshotNeo account to try the 1,000 monthly shots.

FAQ

Does a permission error always mean chmod or Windows ACLs are wrong?

No. The same message can accompany an invalid selector-derived region, an unsupported filename format, a missing directory or a page that is not ready. Prove file access with a broad, known-good render before changing permissions.

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

Should I use a longer sleep instead of waitForSelector?

No. A fixed delay may be too short on a slow run and wasteful on a fast one. Wait for the element or destination state that makes the screenshot meaningful, adding a small delay only for a known animation.

Why can body capture succeed while my panel capture fails?

The page-level render does not need CasperJS to calculate the panel’s selector geometry. The panel may be absent, hidden, zero-sized, inside a frame or being replaced while the body remains renderable.

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.