Use Puppeteer’s ElementHandle.screenshot() to save only a rendered HTML table. Wait for a selector that uniquely identifies the table, obtain a fresh handle after dynamic rendering finishes, and then call table.screenshot({ path: 'table.png' }). This captures the element rather than the entire page and scrolls it into view when necessary.
Capture only the table
The essential workflow is: launch a browser, open the page, wait for the table, and screenshot the returned element handle.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle2' });
const table = await page.waitForSelector('table#results');
if (!table) throw new Error('Table not found');
await table.screenshot({ path: 'table.png' });
} finally {
await browser.close();
}
The file is written as table.png. PNG is Puppeteer’s default screenshot type. The element method captures the selected table, not the surrounding navigation, headings, or page background. Puppeteer scrolls the element into view if required. If the element has been removed or replaced since the handle was created, the screenshot call throws because the handle is detached.
Set up Puppeteer and navigate reliably
Install and import
In a new Node.js project, install Puppeteer:
npm install puppeteer
The example uses an ES module import. If your project is configured for CommonJS, use the equivalent require form supported by your Node.js setup, or enable ES modules in package.json.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Choose a navigation wait
waitUntil: 'networkidle2' waits for a period with no more than two active network connections and is a useful navigation setting. It does not prove that an application has finished fetching or drawing its table. A dashboard can continue rendering after navigation is considered complete, so add a table-specific readiness check.
Use a selector that identifies the intended table
A selector such as table#results is safer than a generic table when several tables appear on the page. CSS selectors work with waitForSelector(). Puppeteer also supports locators and additional selector syntax for text, accessibility attributes, XPath, and open Shadow DOM. Ordinary CSS selectors do not cross a Shadow DOM boundary.
const table = await page.waitForSelector('table#results', {
visible: true,
timeout: 30000
});
if (!table) throw new Error('Results table did not appear');
await table.screenshot({ path: 'results-table.png' });
Use the selector from the page’s actual markup. If the table is inside an open shadow root, select through the appropriate shadow-DOM-aware mechanism instead of expecting a document-level CSS selector to cross the boundary.
Wait for a dynamically populated table
Many pages insert an empty table shell first and populate rows later. Waiting only for the table element can therefore produce a valid image of an incomplete result. Wait for a meaningful application signal, such as a row, a loading indicator disappearing, or a status element reporting completion.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Wait for a result row
await page.goto('https://example.com/report', { waitUntil: 'networkidle2' });
await page.waitForSelector('table#results tbody tr', { visible: true });
const table = await page.waitForSelector('table#results', { visible: true });
if (!table) throw new Error('Table not found');
await table.screenshot({ path: 'report.png' });
Wait for an application-specific status
await page.waitForSelector('[data-testid="report-ready"]', {
visible: true,
timeout: 60000
});
const table = await page.waitForSelector('table#results', { visible: true });
if (!table) throw new Error('Table not found after report became ready');
await table.screenshot({ path: 'report.png' });
Replace these selectors with signals your application actually emits. A fixed delay can be useful as a last resort, but it is less reliable than waiting for the condition that means the data is ready.
Refresh the handle after replacement
Frameworks can replace the entire table node during sorting, filtering, pagination, or hydration. If that happens after you obtained an ElementHandle, the old handle is detached. Wait for the update, then call waitForSelector() again and screenshot the new handle.
await page.click('#load-report');
await page.waitForSelector('[data-testid="report-ready"]', { visible: true });
// Obtain a new handle after the framework has finished replacing the table.
const table = await page.waitForSelector('table#results', { visible: true });
if (!table) throw new Error('Updated table not found');
await table.screenshot({ path: 'updated-report.png' });
Element screenshot versus page screenshot
| Goal | Puppeteer call | Result |
|---|---|---|
| Only the table | table.screenshot({ path: 'table.png' }) |
The selected element, scrolled into view when needed |
| Entire document | page.screenshot({ path: 'page.png', fullPage: true }) |
The full page; fullPage is false by default |
| Custom page rectangle | page.screenshot({ path: 'crop.png', clip: { x, y, width, height } }) |
A specified viewport-region crop |
Choose the boundary that matches the deliverable. An element capture avoids unrelated page content. A full-page capture is appropriate when the table is part of a document whose context matters. A clipped page screenshot is useful when you need a precise rectangle rather than a DOM element.
Output formats and screenshot options
PNG, JPEG, and WebP
Providing path saves the image to disk, and PNG is the default. For a lossy format, specify a supported type and quality:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
await table.screenshot({
path: 'table.jpg',
type: 'jpeg',
quality: 85
});
The quality option applies to supported lossy formats, not PNG. Use a lossless PNG for text-heavy tables when legibility is more important than file size.
Wide and tall tables
An element screenshot is intended to capture the selected element even when it extends beyond the viewport. If the result you need is a page-level crop or a complete page, use clip or fullPage on page.screenshot() instead. Verify the output for your layout, especially with horizontally scrollable tables: the screenshot boundary follows the rendered element and may not represent content hidden behind an inner scroll container.
Device and rendering consistency
Set the viewport before navigation when column wrapping or responsive breakpoints matter:
await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
await page.goto('https://example.com/report', { waitUntil: 'networkidle2' });
Use the same viewport and browser configuration in repeatable jobs. If fonts or images load after the table appears, wait for the application’s ready signal before capturing so the screenshot reflects the final layout.
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 →Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: 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 the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Common failures and fixes
“Table not found” or a timeout
- Inspect the live DOM and correct the selector; the table may use a class, a generated identifier, or a different element such as a grid.
- Increase the timeout only after confirming that the page is expected to take longer.
- Check whether the content is inside an iframe. Navigate or select within the appropriate frame rather than querying the top-level page.
- If it is in an open shadow root, use a shadow-DOM-aware selector strategy.
The screenshot contains an empty table
- Wait for a row, completion marker, or loading indicator to disappear instead of waiting only for the table shell.
- Confirm that the API request supplying rows has completed and that the page is not still paginating.
- Capture a fresh handle after the data framework replaces the table.
“Node is detached from document”
The DOM node changed after you obtained the handle. Perform the state change first, wait for its completion, then call waitForSelector() again. Do not keep and reuse a handle across sorting, filtering, navigation, or re-rendering.
The image is cropped or misses columns
- Determine whether the table itself has an inner horizontal scrollbar.
- Increase the viewport width if the page is using a responsive layout.
- Use a page-level
cliporfullPagecapture when the desired framing is a page rectangle rather than the element’s rendered box.
PNG is unexpectedly large
PNG is lossless and often best for table text, but it can be larger than JPEG or WebP. Choose a supported lossy type and set quality when file size is the priority; do not expect quality to change PNG output.
The capture is taken before visual assets settle
Navigation idleness is not an application readiness guarantee. Wait for the table’s own completion condition, and include any font, image, or chart readiness signal that affects the table’s final appearance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Production checklist
- Launch and close the browser in a
try/finallyblock so failures do not leave Chromium running. - Use a selector specific to the intended table.
- Wait for application-specific rendering, not just navigation idle.
- Obtain a fresh element handle after DOM replacement.
- Choose element, full-page, or clipped capture deliberately.
- Use PNG for lossless table text or a supported lossy type when size matters.
- Set a stable viewport when responsive layout changes the table.
- Save to a known path and handle timeout, missing-selector, and detached-node errors.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF, and its element-capture option can target a table by CSS selector. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—work with Claude, Cursor, and other MCP clients.
For API parameters and all 63 options, see the ScreenshotNeo documentation. A direct request looks like this:
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/report -d selector="table#results" -o table.webp
ScreenshotNeo’s Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Start with a free ScreenshotNeo account.
FAQ
Does Puppeteer capture the table’s HTML or an image?
ElementHandle.screenshot() renders the selected element in the browser and saves an image file.
Can I use a text selector instead of an ID?
Use Puppeteer’s locator and supported selector features when text or accessibility attributes are more stable than generated IDs; ordinary CSS remains the simplest option for a normal table.
What if I need a PDF rather than an image?
Use Puppeteer’s page PDF workflow or ScreenshotNeo’s capture_pdf capability when a PDF output is the required deliverable.
Frequently Asked Questions
Does Puppeteer capture the table’s HTML or an image?
ElementHandle.screenshot() renders the selected element in the browser and saves an image file.
Can I use a text selector instead of an ID?
Use Puppeteer’s locator and supported selector features when text or accessibility attributes are more stable than generated IDs; ordinary CSS remains the simplest option for a normal table.
What if I need a PDF rather than an image?
Use Puppeteer’s page PDF workflow or ScreenshotNeo’s capture_pdf capability when a PDF output is the required deliverable.
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 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQuick 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.




