Use Java Playwright’s Page.screenshot() to save an Indian Railways timetable page as an image. Set setFullPage(true) to include content below the viewport—but first submit a train query and wait for its result. Full-page capture does not run the search or load the timetable for you.
What this example captures—and what it does not
The example uses the Indian Railways Passenger Reservation Enquiry Train Schedule page: https://indianrail.gov.in/enquiry/SCHEDULE/TrainSchedule.html?locale=en2. The page states, “Train Schedule is shown only for reserved trains defined in the PRS system.” This is not a claim that the page covers every train or timetable source.
The page presents a query form; opening it without submitting a train name or number captures the form and its initial state, not a train timetable. The government service listing says users can search with at least three characters of a train name or number and see schedule details including train name and number, source, running days, and destination. That listing was last updated April 30, 2026; the live interface and data may change. See the National Government Services Portal listing.
Set up Playwright for Java
Playwright’s Java installation guide requires Java 8 or higher and documents the dependency and browser installation steps for a project. Follow the guide for your build system and installed Playwright version: Java installation and getting started. Playwright browsers run headless by default, so this capture can run without displaying a browser window.
#1 Best Overall
- 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.
The example below uses Chromium, navigates to the official schedule page, and saves a full-page PNG. It is a runnable capture of the page as initially loaded; it deliberately does not claim to query or capture a particular train.
Save the timetable page as a full-page image
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import java.nio.file.Paths;
public class CaptureTimetable {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
try {
Page page = browser.newPage();
page.navigate("https://indianrail.gov.in/enquiry/SCHEDULE/TrainSchedule.html?locale=en2");
page.screenshot(new Page.ScreenshotOptions()
.setPath(Paths.get("timetable.png"))
.setFullPage(true));
} finally {
browser.close();
}
}
}
}
Compile and run this class using the Playwright dependency and browser installation configured by the official Java guide. The output path is relative to the process’s working directory; change it to an absolute path if your application needs a predictable location. This code captures the page after navigation, but does not submit a train search.
Capture an actual train result
To save a result rather than the search form, the browser flow must interact with the page’s real controls. The exact selectors and submission behavior are properties of the live site and should be confirmed against its current markup; do not assume a selector that has not been checked.
Rank #2
- 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.
- Navigate to the schedule page.
- Locate the train name/number input using the current page’s accessible label or inspected selector, then enter a valid query. The government listing describes a minimum of three characters.
- Submit the query using the page’s current control.
- Wait for the result content—not merely navigation—to appear. Prefer a locator for a distinctive result heading or schedule table row; a fixed delay is less reliable because response time varies.
- Capture the page or the result element, depending on what needs to be preserved.
Because the live page’s current input and result selectors are not established here, the code above does not fabricate them. Add the verified locators for the version of the site you are automating. A screenshot taken before the result appears can be a technically successful image of the wrong state.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choose the right screenshot scope
| Capture | Use it when | Java approach |
|---|---|---|
| Viewport | You need only the visible screen and want a compact image. | page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("timetable.png"))) |
| Full page | The timetable extends below the visible viewport and the whole document should be recorded. | Add .setFullPage(true). |
| One element | You want a bounded result table without surrounding page chrome and have a stable locator. | Use locator.screenshot(...) on the verified table locator. |
The official Java Screenshots guide also documents returning screenshot bytes, clipping to a region, and element screenshots. For a scrollable element, a locator screenshot shows the element’s currently scrolled content; it does not automatically capture all content hidden inside that element.
Useful screenshot options
The Java Page API reference documents screenshot options including path, image type, scale, animation handling, masks, timeout, and full-page mode. Check the API reference matching your installed Playwright version, especially if choosing a format beyond PNG.
Rank #3
- 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.
- Path:
setPath(Paths.get("timetable.png"))writes the image to a file. Without a path, screenshot bytes can be returned for further processing. - Full page:
setFullPage(true)expands the capture to the full scrollable page. It does not submit a query or wait for dynamic results. - Format and scale: Choose these when image size or rendering density matters. Format availability and exact options depend on the installed Playwright version.
- Clipping or locator capture: Use a clip rectangle or a locator when only a specific region or schedule table belongs in the record.
- Animation and masks: These options can help make repeated captures more consistent or obscure selected page content; use them only when appropriate to the purpose of the record.
- Timeout: The Page API reference documents a default screenshot timeout of 30,000 ms. This is a software default, not a guarantee that the page or a timetable query will finish within that time.
Make screenshots useful as records
If the image is evidence or will be compared with later captures, keep its context with it. Record the queried train, capture time, browser and version, viewport settings, and whether the image is viewport, full-page, or element-only. Those details help explain differences between images; the screenshot itself is only a visual record of the state that was present when captured.
Troubleshooting
The screenshot contains only the search form
The example captures the page without running a query. Submit a train name or number through the current page controls, then wait for the result locator to appear before taking the screenshot.
The screenshot is cut off below the visible area
Enable setFullPage(true) for a full-document capture. If you used an element screenshot on a scrollable table, it may include only the content currently visible inside that element; capture the page or handle the table’s scrolling separately.
Rank #4
- 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
The image file is missing
Check the process’s working directory and the path passed to setPath. Use an absolute path when the application’s launch directory is not predictable, and verify that the process can write to the destination.
The capture times out
Check that navigation and browser installation succeeded, then inspect whether the page is still loading or the screenshot operation itself is timing out. The API’s 30-second screenshot default is not a page-readiness strategy; wait explicitly for the result you intend to capture and adjust the relevant timeout only when needed.
A locator no longer finds the input or table
The live site may have changed its markup. Recheck the current page and use an accessible label or a verified selector rather than relying on an outdated selector. The page’s initial empty state is not proof that a query succeeded.
Best Value
- 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.
The saved image is unexpectedly large
A full-page capture includes the entire document, which can be much taller than the viewport. Use a viewport screenshot, clip, or element screenshot if the record only needs the relevant portion.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo offers a one-request screenshot API at screenshotneo.com. Its clean-shot steps accept cookie/consent banners and remove 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. It also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.
For a simple full-page screenshot, call the API with your access key and the timetable URL. See the ScreenshotNeo API documentation for options and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://indianrail.gov.in/enquiry/SCHEDULE/TrainSchedule.html?locale=en2 -o timetable.webp
This captures the URL as requested; it does not submit the railway form on your behalf. For a result image, first use a URL or workflow that has the desired query and result state. ScreenshotNeo’s free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo free.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Frequently Asked Questions
Can I save a Playwright screenshot as bytes instead of a file?
Yes. The Java screenshot API can return image bytes when you omit the path, so your application can process or store the image itself.
Does the Indian Railways schedule page show every train?
No. The page says it shows schedules only for reserved trains defined in the PRS system.
Can I use a screenshot as proof of a train’s current operating status?
A screenshot records the page state displayed at capture time; it does not by itself establish live running status or guarantee that the schedule remains current.
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.

