Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To capture a Selenium screenshot of an HTML table with its intended custom font, wait until the table is in its final state, explicitly load the needed font face if necessary, then await document.fonts.ready before taking the screenshot. Use the table element’s screenshot method for a tight crop, or a page/window screenshot when you need surrounding context. A fixed sleep alone cannot confirm that the font loaded.
Why a Selenium screenshot can show the wrong font
A page can finish navigating before a web font has been requested or loaded. Browsers may fetch a font only when page content needs it, and a table that appears after an interaction or data update may trigger font loading later still. If Selenium captures during that interval, the browser can render with a fallback face or with layout that changes once the intended font becomes available. The CSS Font Loading API exposes the document’s font state and lets a script request matching faces directly (MDN: CSS Font Loading API).
The reliable sequence is: wait for the table and its data, request the relevant face when a particular family matters, await font readiness, and then capture. document.fonts.ready resolves after fonts used by the document have loaded and related layout operations are complete, with no further font loads needed at that point (MDN: FontFaceSet.ready). It does not guarantee that every font declared in the stylesheet, every weight, or every character in every font has loaded. A face that is not used may remain unloaded (MDN: Document.fonts).
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, 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 minuteCapture a table after its custom font is ready
This Python example assumes Selenium is already installed, a compatible browser and driver are available, and the page can be accessed in that browser. Replace the URL, selector, family, and representative text with values from the page under test. The pattern is based on the documented Selenium and browser APIs; it is an example, not a claim of execution across every driver.
#1 Best Overall
- Integrated Video Conferencing Features: Full HD adjustable webcam, mic array and stereo speakers for video conferencing and online learning
- Display Specifications: 27-inch Full HD (1920 x 1080) frameless IPS panel with wide viewing angles for enhanced visual experience
- Extensive Connectivity Options: DisplayPort, HDMI, D-sub, USB (upstream for webcam), Audio in and Earphone jack for maximum flexibility
- Ergonomic Design: +35 -5 tilt, 180 swivel, 90 pivot and 150mm height adjustments for a comfortable viewing experience
- Eye Care Technology: TV Rheinland-certified Flicker-free and Low Blue Light technologies to ensure a comfortable viewing experience
- Navigate and wait for the table’s real state. Wait for the result table to exist and for any asynchronous data or interaction that populates it to finish. A table element appearing in the DOM does not necessarily mean its rows are final.
- Set an adequate asynchronous-script timeout. The font readiness promise must be allowed to resolve before the script times out.
- Request the particular face if it is required. Use a CSS font descriptor that matches the table’s actual size, family, weight, and style. Include representative characters from the table.
- Await document font readiness, then capture. Use the WebElement screenshot for the table itself, or switch to a page/window screenshot if the result needs context.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
URL = "https://example.com/reports"
TABLE_SELECTOR = "table.results"
FONT_DESCRIPTOR = '14px "Brand Sans"'
SAMPLE_TEXT = "Quarterly report 0123456789"
# Create the driver appropriate for your installed browser and driver.
driver = webdriver.Chrome()
try:
driver.set_script_timeout(20)
driver.get(URL)
# Wait for the table element. Add an application-specific condition here
# if rows load asynchronously or require a user action.
table = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.CSS_SELECTOR, TABLE_SELECTOR))
)
# Explicitly request the face that the table is expected to use.
# Rejection is surfaced as a failed Selenium script rather than ignored.
driver.execute_async_script("""
const descriptor = arguments[0];
const sample = arguments[1];
const done = arguments[arguments.length - 1];
document.fonts.load(descriptor, sample).then(
faces => {
if (faces.length === 0) {
done(new Error("No matching font faces were loaded"));
return;
}
document.fonts.ready.then(() => done(true), done);
},
done
);
""", FONT_DESCRIPTOR, SAMPLE_TEXT)
table.screenshot("table.png")
finally:
driver.quit()
document.fonts.load(font, text) requests faces matching the supplied CSS font string and text; its promise rejects when loading fails. It is useful for making a font failure visible, but a successful request does not certify that every glyph exists in the intended font or that all table styles use that face (MDN: FontFaceSet.load()). Match the descriptor to the table’s computed typography. For example, if the table uses bold 14-pixel text, requesting only a regular 14-pixel face may not exercise the bold face that matters.
The sample checks that at least one matching face was returned. If the page legitimately uses a fallback or system font, adjust that assertion to your test’s expected behavior rather than treating any non-match as a browser failure. For the simpler case where the page itself determines all required faces, wait for readiness with:
driver.execute_async_script("""
const done = arguments[arguments.length - 1];
document.fonts.ready.then(() => done(true), done);
""")
Selenium’s asynchronous script API uses the final supplied argument as the completion callback. Configure a script timeout that reflects the page and network conditions. A timeout is a signal to investigate the page’s load state, font request, or script execution; it is not a reason to silently take a screenshot and assume the font is correct.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- Versatile Full HD IPS Display: Elevate your home office or study space with this 32 Inch 1080p (1920 x 1080) LED monitor; enjoy an IPS panel that delivers consistent colors and wide viewing angles for clear visuals from any perspective
- Smooth Adaptive Sync Performance: Enjoy fluid visuals for casual gaming and multimedia with VESA Adaptive Sync technology; this feature enables a smooth 75Hz refresh rate to ensure consistent frame rates and reduced screen tearing for a seamless experience
- Enhanced Viewing Comfort: Minimize eye fatigue during long workdays or study sessions with integrated Flicker-Free technology and a Blue Light Filter; these eye care features provide a more comfortable viewing experience for students and professionals
- Tailored ViewMode Settings: Optimize screen performance with ViewSonic exclusive ViewMode presets; quickly switch between “Game,” “Movie,” “Web,” “Text,” and “Mono” modes to get the ideal gamma curve, contrast, and brightness for any task or application
- Flexible Connectivity: Seamlessly connect your laptops, PCs, and Macs with versatile input options; this monitor features HDMI and VGA inputs, providing the reliable compatibility needed for both modern hardware and legacy devices in any setup
Choose the screenshot boundary that matches the test
| What the image needs to show | Capture method | What to check |
|---|---|---|
| Only the table | Call screenshot(path) on the table WebElement. |
Inspect clipping, table overflow, and any scrollable container. Selenium’s Python WebElement API documents screenshot saving and PNG data methods (Selenium WebElement documentation). |
| The table with its heading, legend, or nearby controls | Capture the page or browser window using the driver screenshot API. | Set the viewport and scroll position consistently. A window screenshot should not be assumed to include the entire document in every implementation; Selenium’s driver documentation describes the available screenshot methods (Selenium WebDriver documentation). |
| Equivalent output across browsers or environments | Use the capture method supported by the target browser/driver and validate it there. | Record browser, driver, Selenium version, viewport, and operating environment. Selenium’s Java TakesScreenshot API describes non-W3C behavior as best effort, so one driver’s behavior should not be generalized to all others (Selenium TakesScreenshot documentation). |
For an element-only image in Python, the relevant call is table.screenshot("table.png"). The file is PNG. The WebElement API also provides methods for retrieving screenshot data rather than writing to a path. In other Selenium bindings, use the corresponding element screenshot method when available; confirm the behavior in the binding and driver you actually run.
Make the capture repeatable
Wait for application state, not just page navigation
Navigation completion is not proof that the table contains its final rows. Wait on a stable, meaningful condition: for example, a known table selector, a loading indicator disappearing, or an expected row count. If a click, filter, or sort changes the table, perform that action first and then wait for the resulting state before checking fonts.
Wait again after changes that can trigger fonts
The readiness promise concerns the current document’s font loading and layout work. If the application reveals new content, changes typography, or loads a table after the initial wait, that action may require another font readiness check. Await readiness after the final state-changing operation, not merely once immediately after navigation.
Rank #3
- VIVID COLORS: Experience stunning colors across the entire display with the IPS panel. Colors remain bright and clear across the screen, even when you change angles. Tones and shades are represented consistently and beautifully with less color washing.
- SMOOTH PERFORMANCE: Stay in the action when playing games, watching videos, or working on creative projects. The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments.¹
- MORE GAMING POWER: Gain a competitive edge with optimizable game settings. Color and image contrast can be instantly adjusted to see scenes more clearly, while Game Mode adjusts any game to fill your screen with every detail in view.
- EASY ON THE EYES: Protect your vision and stay comfortable, even during long sessions. Stay focused on your work with reduced blue light and screen flicker.²
- A MODERN AESTHETIC: Featuring a super-slim design with ultra-thin border bezels, this monitor enhances any setup with a sleek, modern look. Enjoy a lightweight and stylish addition to any environment.
Use representative characters
The text passed to document.fonts.load() should reflect the table’s actual content, including relevant digits, punctuation, symbols, and writing systems. A page may successfully load a Latin face while a different script or uncommon symbol is rendered by fallback. The font-loading API can request matching faces, but it does not establish complete glyph coverage.
Keep capture conditions controlled
- Set a consistent browser window or viewport size so wrapping and column widths do not vary unexpectedly.
- Use deterministic table data and wait for asynchronous updates to finish.
- Keep the page at a known scroll position when capturing the page or window.
- Use the same browser, driver, and operating environment for comparisons unless cross-environment rendering is specifically what the test measures.
- Inspect the saved image for font appearance, table overflow, clipping, and content completeness.
Troubleshooting font and screenshot failures
The image shows a fallback font
Inspect the table’s computed font family, size, weight, and style, then check the matching FontFace entries and their statuses. Confirm the font request succeeded in the browser’s network environment and that the requested face covers the table’s characters. Explicitly call document.fonts.load() with the correct descriptor and sample text. A successful document.fonts.ready alone is not proof that an unused or unmatched face loaded.
The page is ready but the screenshot is not
Page navigation and font readiness represent different conditions. Wait for the table’s content and any interaction-driven update first; then wait for the relevant font work and capture. Fonts may be fetched lazily when they become necessary, so an early wait can precede the request.
Rank #4
- Complete Video Conferencing Solution: Ready for telecommuting and online learning with integrated 2MP adjustable Full HD webcam, mic array and stereo speakers for seamless communication
- Display Specifications: Aspect Ratio is 16:9 with Viewing Angle (CR10) of 178/ 178 and Brightness (Typ) of 300cd/ for consistent visibility from multiple positions
- Full HD Frameless Display: 24-inch 16:9 Full HD (1920 x 1080) frameless IPS panel with wide viewing angles for immersive visual experience
- Advanced Audio Technology: Beamforming and echo cancellation technology to filter out ambient noise including keyboard clicks and to further enhance speech clarity during calls
- Eye Care Technology: ASUS Eye Care Technology with TV Rheinland Certification for Flicker-free and Low Blue Light technology to reduce eye fatigue associated with extended viewing
The table screenshot is clipped or incomplete
Check whether the table sits inside a horizontally or vertically scrollable container, whether the target browser’s element screenshot includes the content you expect, and whether the table extends beyond its rendered element bounds. Compare an element capture with a page capture to distinguish element-boundary behavior from layout or overflow issues. Driver implementations can differ, so validate the exact setup.
The result is intermittent
Replace arbitrary fixed sleeps with explicit waits for application state and font promises. If client-side code can insert content or trigger additional font loads after the first wait, wait for the final update and await readiness again. Also ensure the test does not capture while another action is changing the table.
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 →The font-loading promise rejects or returns no matching face
Treat this as a failed precondition when the test requires that face. Check the font URL and network response, CSS @font-face declaration, requested family and weight, browser access to the font, and the text passed to the load call. A rejected promise should be visible in the test report rather than hidden behind a delay. The Font Loading API exposes failed font status and loading errors for diagnosis.
Best Value
- VIVID COLORS: Experience stunning colors across the entire display with the IPS panel. Colors remain bright and clear across the screen, even when you change angles. Tones and shades are represented consistently and beautifully with less color washing.
- SMOOTH PERFORMANCE: Stay in the action when playing games, watching videos, or working on creative projects. The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments.¹
- MORE GAMING POWER: Gain a competitive edge with optimizable game settings. Color and image contrast can be instantly adjusted to see scenes more clearly, while Game Mode adjusts any game to fill your screen with every detail in view.
- EASY ON THE EYES: Protect your vision and stay comfortable, even during long sessions. Stay focused on your work with reduced blue light and screen flicker.²
- A MODERN AESTHETIC: Featuring a super-slim design with ultra-thin border bezels, this monitor enhances any setup with a sleek, modern look. Enjoy a lightweight and stylish addition to any environment.
The async script times out
Confirm that the browser script reaches its completion callback and that the configured Selenium script timeout is long enough for the expected loading work. If the font request itself is stuck or blocked, increasing the timeout only postpones the failure; inspect the browser’s network and font state. Keep separate timeouts for waiting on application elements and for running asynchronous JavaScript where your test framework permits it.
Or skip the browser setup
If you need a screenshot of a publicly reachable page rather than a Selenium-controlled test session, ScreenshotNeo can return a screenshot or PDF from one GET request. It is not a replacement for validating your application’s Selenium behavior, but it can avoid setting up a browser for straightforward captures. For API parameters and options, see the ScreenshotNeo documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Use your own API key and replace the target URL with the page you want. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. 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.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →When this workflow is the right fit
Use Selenium when the screenshot is part of a browser test and you need control over interactions, page state, or the exact browser environment. Use an element capture when the table alone is the test artifact; use a page capture when context matters. The font readiness and explicit face-loading gates make the capture more defensible than a guessed delay, while the final image remains the practical check that the intended font, table content, and crop are all present.
Frequently Asked Questions
Does `document.fonts.ready` wait for every font declared in a stylesheet?
No. It resolves for the document’s current font-loading and layout work; faces that are not used may remain unloaded.
Can `document.fonts.load()` prove that every table character has the right glyph?
No. It requests matching faces for the supplied descriptor and text, but does not certify that every glyph is covered.
Which screenshot API should I use for a table-only PNG in Selenium Python?
Use the table WebElement’s `screenshot(path)` method; use the driver’s screenshot method when the page or window context is part of the artifact.
Recommended Free Tools
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.

