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

If page.goto() throws net::ERR_ABORTED while opening a PDF in headless Playwright, the browser’s built-in PDF navigation is a likely cause: Playwright documents that headless mode does not support navigating to a PDF document. The reliable fix is to match your test to its real goal—download the file, inspect its response, parse its contents, or test the PDF viewer—instead of treating a PDF URL like an ordinary HTML page.

Why headless Playwright can abort navigation to a PDF

A PDF URL may return a valid document without producing a normal web page. Playwright’s Page API documents that headless mode does not support navigation to a PDF document. A Playwright issue reports net::ERR_ABORTED in that situation, so the error is consistent with the limitation when it occurs on a headless PDF navigation.

That does not mean every net::ERR_ABORTED has the same cause. A failed main-resource load, a redirect, a server response, or other browser behavior can also interrupt navigation. Diagnose the request and response rather than assuming the error itself proves that the PDF is invalid.

There is an important distinction: navigating to a URL is not the same as obtaining a file. A navigation may instead become a download, depending on how the server serves the resource and how the browser handles it. Decide what the test must prove before choosing an API.

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.

Choose the right workflow for the test

Goal Recommended workflow What to assert
Confirm a link downloads a PDF Wait for Playwright’s download event around the click and save the download. That a download occurred and the saved file is present and valid.
Check the server’s PDF response Request the resource and inspect its status, headers, and bytes. The response is successful and contains PDF data, not an HTML error page.
Search or verify document text Obtain the file, then parse its bytes with a PDF parser. The expected text or other document-level property exists.
Test the browser’s PDF viewer Run a viewer-focused test in the exact browser and mode you support. The relevant viewer UI works in that configuration.

Keep these assertions separate. A successful file download does not establish that a built-in viewer rendered correctly; a viewer navigation error does not establish that the server failed to deliver a valid PDF.

Download a PDF through a link

For a link expected to download a file, register the download wait before clicking. This avoids missing a fast download event. The example uses Playwright’s JavaScript API and a link accessible by its role and name; change the locator to match your page.

const downloadPromise = page.waitForEvent('download');
await page.getByRole('link', { name: 'Download PDF' }).click();
const download = await downloadPromise;

await download.saveAs('sample.pdf');

If the page opens a new tab or window rather than initiating a download, wait for the corresponding page event and inspect what it actually does. Do not assume that a click must produce a download simply because the target ends in .pdf; servers may serve PDFs inline, redirect, or return an error.

Check the saved file

After saving, assert the file exists and is non-empty. For stronger verification, inspect its bytes or pass it to a PDF parser. A filename ending in .pdf is not proof that the content is a PDF: error pages and access-denied responses can be saved with that extension too.

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.
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.

Fetch and inspect the PDF response

If you do not need to exercise a browser download or viewer, request the PDF directly and inspect the response. This avoids relying on headless PDF navigation. The following Node.js example uses Playwright’s request API; set the URL to the resource under test.

const response = await page.request.get('https://example.com/sample.pdf');

if (!response.ok()) {
  throw new Error(`PDF request failed: ${response.status()} ${response.statusText()}`);
}

const contentType = response.headers()['content-type'] ?? '';
const bytes = await response.body();

if (!contentType.toLowerCase().includes('application/pdf')) {
  throw new Error(`Expected a PDF response, received: ${contentType || 'no content-type'}`);
}

if (bytes.length < 5 || bytes.subarray(0, 5).toString() !== '%PDF-') {
  throw new Error('Response does not begin with a PDF signature');
}

Content type and the PDF signature are useful checks, but neither replaces parsing when your requirement concerns document contents. Some servers configure content types incorrectly, while a response can be a structurally damaged PDF despite beginning with the expected signature. For text or page assertions, pass the bytes to a PDF parser and assert its output.

If the request requires authentication, cookies, or headers, make sure the request uses the relevant credentials. A direct request may not automatically reproduce every detail of an interactive browser session. In that case, use an appropriate authenticated request context or exercise the page’s actual download flow.

Make an inline PDF behave like a download when necessary

A PDF served inline may be handled as browser content rather than as a download. A workaround shown in a Playwright issue discussion is to intercept the resource, fetch its response, and fulfill the route with a Content-Disposition: attachment header. This changes how the test receives the response; it does not test the site’s unmodified delivery behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
await page.route('**/*.pdf', async route => {
  const response = await route.fetch();
  await route.fulfill({
    response,
    headers: {
      ...response.headers(),
      'content-disposition': 'attachment; filename="document.pdf"'
    }
  });
});

const downloadPromise = page.waitForEvent('download');
await page.goto('https://example.com/document.pdf');
const download = await downloadPromise;
await download.saveAs('document.pdf');

Validate this approach against your Playwright version and target server. Route matching, redirects, response headers, and the site’s own download behavior can affect the result. Use it when the test specifically needs download semantics; do not use it to claim that the site itself serves the PDF as an attachment.

When the requirement is to test the PDF viewer

If your product requirement is that a user can view a PDF inside the browser, file retrieval is not an equivalent test. Treat viewer behavior as a browser-configuration-specific UI scenario. Compare headed and headless runs only as a diagnostic, and record the Playwright version, browser engine and version, launch mode, and relevant runtime configuration with the result.

The documented headless restriction means switching lifecycle waits is not a universal fix. waitUntil: 'commit', 'domcontentloaded', or 'load' changes what navigation completion means; it does not remove the PDF-navigation limitation. Likewise, catching and ignoring the navigation exception can make a test green without proving that a viewer appeared or a file was received.

Playwright issue discussions also describe differences in headless Chromium’s PDF viewer and download handling. Treat those reports as configuration-specific evidence, not as a promise that headed mode always works or that all Chromium versions behave alike.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Troubleshooting common failures

  • page.goto() throws net::ERR_ABORTED on a PDF in headless mode: stop treating the PDF as an ordinary page. If you need the file, use a download or response workflow. If you need viewer behavior, test the exact supported browser configuration.
  • The download wait times out: verify that the click targets the intended link and that the server actually triggers a download. Check for redirects, authentication requirements, or inline PDF handling. Register the wait before the action.
  • The request succeeds but the file is not a PDF: inspect the response status, content type, and initial bytes. The URL may return a login page, bot check, or other HTML response instead of the document.
  • The PDF downloads but expected text is missing: validate the saved file, then parse its contents. A browser download assertion alone does not test document text; scanned pages may also need OCR, which is separate from PDF navigation.
  • A route workaround does not trigger a download: check that the route pattern matches the actual URL, including redirects, and that the fulfilled response retains the needed headers and body. Confirm the behavior on the current Playwright version and server.
  • Changing waitUntil does not help: use a file-oriented workflow. Navigation lifecycle settings do not make headless PDF viewer navigation supported.
  • Ignoring the exception makes the test pass: add an assertion for the intended outcome—download, valid response, parsed content, or visible viewer UI—instead of treating absence of a thrown error as success.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Choose the narrowest operation that proves the requirement. A response request avoids browser rendering when only the document data matters; a download flow covers user-facing link behavior; parsing adds work but is necessary for content assertions; a viewer test exercises the full browser path and is the most sensitive to browser configuration.

For reliable tests, separate network failures from PDF parsing failures and viewer failures. Capture status and response metadata, preserve the downloaded file when a test fails, and report the Playwright and browser versions. Avoid retrying every abort as though it were transient: a documented mode limitation will not be fixed by repeated navigation attempts.

No specific runtime benchmark or universal cost figure is established for these workflows. Measure them in your own environment if execution time or infrastructure cost determines which route to use.

Or skip the browser setup

If the goal is a screenshot of a web page rather than downloading or parsing a PDF, ScreenshotNeo provides a screenshot API and MCP server. It is not a replacement for a PDF parser or a test of the browser’s built-in PDF viewer. For page capture, its API can return an image or PDF; cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; and 1,000 screenshots a month are free with no card, with paid plans starting at $5 for 3,000.

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

Example request (see the ScreenshotNeo API documentation):

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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Sign up for 1,000 free screenshots a month—no card required.

Frequently Asked Questions

Does `net::ERR_ABORTED` always mean a PDF caused the failure?

No. It is consistent with the documented headless PDF-navigation limitation in that scenario, but the error can arise in other navigation circumstances too.

Will switching to headed mode guarantee that a PDF opens?

No. The documented limitation concerns headless mode; reports about headed behavior depend on the browser and configuration.

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.

Can I use `page.goto()` to verify PDF contents?

Not reliably in headless mode. Retrieve the file and parse its bytes for content assertions.

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.