Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Use Selenium to test the browser action, then validate the PDF itself with an HTTP client or a PDF library. For a download, Selenium can click a link and provide session context, but WebDriver does not expose download progress; for a PDF generated from a webpage, Selenium’s print API can return PDF data for inspection. Keep download, print-generation, and in-browser viewing tests distinct because each can fail for different reasons.
Choose the PDF workflow you need to test
Start by identifying where the PDF comes from. The right assertions depend on whether your application serves a file, displays a PDF in the browser, or creates a PDF by printing a webpage.
| Workflow | Use Selenium for | Validate | Key limitation |
|---|---|---|---|
| Download an existing PDF | Find the expected link and initiate the user-facing action. | Request result, saved file, and document contents. | WebDriver does not report download progress; use an HTTP client for transfer checks. Selenium file-download guidance. |
| Generate a PDF from a webpage | Call the browser print interface with the required print settings. | Returned PDF bytes, saved file, extracted text, and—if required—visual layout. | Print APIs differ by language binding and interface. Selenium print documentation. |
| Open or interact with a PDF viewer | Test browser-specific display and viewer interactions. | Expected viewer state, controls, or form behavior. | Viewer behavior depends on browser and configuration; it is not a universal WebDriver contract. Selenium supported browsers. |
Test a PDF download without relying on WebDriver progress
Selenium’s official guidance recommends using the browser to locate the link and obtain any required cookies, then retrieving the resource with an HTTP client such as curl. This separates the browser interaction from transfer and file validation.
- Locate the link with Selenium. Assert that the expected download control exists and obtain its destination URL. If clicking is important to the user flow, click it and verify the resulting navigation or request behavior your application exposes.
- Carry authentication into the HTTP request. If the PDF requires a logged-in session, collect the relevant browser cookies and supply them to the HTTP client. Do not assume an unauthenticated request tests the same path as the browser session.
- Request and save the file. Check the HTTP response status and write the response bytes to a controlled test location. Check the response content type as a useful signal, but do not treat it alone as proof that the file is a valid PDF.
- Validate the saved document. Confirm that the file exists and is non-empty, then use a PDF parser to check expected content or requirements such as PDF/A conformance.
Selenium explicitly cautions that its API does not expose download progress, so a WebDriver click by itself cannot establish that a complete file was transferred. See the official download testing guidance for the recommended separation.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- The FreeStyle log book includes sections for: Lunch, Dinner, Bedtime, Night
- Comments for each day of the week
- Log Book Dimensions L=4.25" x W=3.12" x H=0.12"
- Contains 5 book
Example: use curl after obtaining the URL and cookies
Replace the URL and cookie values with those obtained for your test session. The command writes the response to a predictable path; your test should also check the HTTP status and then inspect the saved file with a PDF library.
curl --fail --location
--cookie "SESSION=YOUR_SESSION_COOKIE"
"https://example.com/report.pdf"
--output /tmp/report.pdf
This is a shell example, not a Selenium API call. Integrate the HTTP request and response assertions in your test language if you need automated status checks and cleanup.
Rank #2
Generate a PDF from a webpage with Selenium
When printing the current page is the product behavior under test, use Selenium’s print interface and configure the options that matter to your output. The official documentation describes orientation, margins, scaling, background printing, and shrink-to-fit. The Java PrintsPage path returns base64-encoded PDF data that can be decoded and saved; Selenium also documents a BiDi BrowsingContext printing path. Consult the current print documentation for the API shape in your chosen language and interface.
- Navigate to the page and wait for the content that should appear in the document.
- Set print options to match the intended output, including orientation, margins, scaling, background output, or shrink-to-fit where relevant.
- Invoke the print API and obtain its PDF data. Decode base64 data when the selected binding returns it in that form.
- Write the decoded bytes to a test file and run document assertions against that file.
Do not test only that the print command returned successfully: the resulting bytes and the document content are the evidence that the PDF was generated as expected. The APIs and capabilities can vary across bindings, so avoid copying a code sample for another language as though it were portable.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
Validate PDF content and conformance
Use a PDF-aware library for document checks rather than treating the browser’s PDF viewer as a text document. Apache PDFBox is a Java PDF library that supports Unicode text extraction, form handling, and PDF/A-1b preflight validation. Its project page lists PDFBox 3.0.8, released July 11, 2026, and 2.0.37, released July 15, 2026; those are release facts, not a universal recommendation about which version a project should use. See Apache PDFBox.
- Text requirements: extract text and assert important labels, values, or identifiers that must be present.
- File integrity: ensure the parser can open the file and that required pages or document structures are available.
- PDF/A: run PDF/A-1b preflight validation only when that conformance level is a product requirement.
- Visual requirements: text extraction does not establish layout fidelity. If page geometry, clipping, fonts, or visual appearance matter, add a rendering-based comparison appropriate to the project.
Test browser PDF viewing separately
A successful download or valid PDF does not prove that a particular browser presents it as expected. Firefox uses its built-in viewer when PDFs are configured to open in Firefox, which Mozilla says is the default setting; an incorrectly set MIME type is a documented exception. See Mozilla’s Firefox PDF viewer guidance.
Rank #4
Keep viewer-specific assertions scoped to the browser and configuration you support. Selenium documents browser-specific capabilities, so do not assume viewer selectors or driver preferences are portable across browsers. If the application contract is the PDF response itself, assert the response and document rather than relying on a browser viewer’s internal UI.
Common failures and how to diagnose them
- The test clicks Download but cannot tell whether transfer finished. This is expected: WebDriver does not expose download progress. Retrieve the file through an HTTP client and assert its response and contents.
- The HTTP request returns an authorization error. The request may not include the browser session’s required cookies or other authentication. Transfer the necessary session state into the HTTP client request, and verify that it targets the link found by Selenium.
- A file exists but PDF parsing fails. A saved response is not necessarily a valid PDF; it could be an error page or incomplete response. Check the HTTP status and inspect the bytes with a PDF parser before treating it as a document.
- Text assertions pass but the page looks wrong. Text extraction cannot verify visual fidelity. Add a rendered-page check for layout-sensitive requirements.
- The PDF opens in a different place or viewer than expected. Browser settings and MIME type influence presentation. Scope the test to the browser configuration and check the served MIME type where relevant.
- A print call works in one binding but not another. Selenium has language- and interface-specific print APIs. Use the current documentation for the binding and interface in your project rather than assuming a single cross-language call.
Or skip the browser setup
If your test needs a screenshot or PDF capture of a webpage rather than validation of your application’s download or print workflow, ScreenshotNeo offers a one-request capture API. For example, this cURL request saves a WebP screenshot of the target page:
Best Value
- Format: Comb Bound Book & Enhanced CD
- Version: CD Kit (Book & Enhanced CD) (Includes Reproducible Student Pages)
- Category: General Music and Classroom Publications
- Contributors: By Jay Althouse and Judy O'Reilly
- Pub Date: 7/2001
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for request options. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. An MCP server provides screenshot tools for AI agents, and the free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. This captures a webpage; it does not replace testing the authenticated download or print behavior your Selenium test is meant to cover.
Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Can Selenium validate the text inside a downloaded PDF?
Selenium handles browser interaction; use a PDF library such as Apache PDFBox to extract and assert document text.
Does Selenium’s print API work the same way in every language?
No. Use the current Selenium print documentation for your language binding and chosen interface.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteShould I automate the built-in PDF viewer for every browser?
Only for browser-specific viewer behavior you need to support. Viewer behavior and capabilities vary by browser and configuration.
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.




