How to capture a screenshot of an Indian university results page with Selenium
Use Python Selenium to wait for an authorized university result to appear, then save a PNG. Learn when to use viewport or full-page capture and how to troubleshoot failures.
Use Selenium to open the official results page, wait until the result content is visible, and save a PNG with driver.save_screenshot("university_results.png"). Navigation finishing does not guarantee that a JavaScript-rendered result is ready. You need the official portal URL and a locator that matches its actual result heading or panel; this guide uses placeholders because no university or portal was specified. Follow the portal’s access terms and use only pages you are authorized to view.
1. Install Selenium and prepare the official page
Install Selenium in your Python environment:
python -m pip install selenium
Use the official portal URL and inspect the authorized result view to identify a stable CSS selector for the result panel, table, or heading. Do not copy the example placeholder literally. This workflow does not assume a particular university’s URL, page layout, login process, or access rules.
2. Capture a result after it becomes visible
This runnable template uses Selenium’s explicit wait and current-window PNG screenshot method. Replace both placeholders before running it. Selenium’s Python API documents that save_screenshot saves the current window and returns False if an I/O error prevents saving. Selenium Python WebDriver API
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
URL = "OFFICIAL_RESULTS_PAGE_URL"
RESULT_SELECTOR = "YOUR_RESULT_SELECTOR"
OUTPUT = Path("university_results.png")
options = webdriver.ChromeOptions()
# Optional for a non-interactive environment. Remove this line to see the browser.
options.add_argument("--headless")
# Selenium Manager can manage the browser driver in supported setups.
driver = webdriver.Chrome(options=options)
try:
driver.set_window_size(1440, 1100)
driver.set_page_load_timeout(30)
driver.get(URL)
result = WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, RESULT_SELECTOR))
)
if not driver.save_screenshot(str(OUTPUT)):
raise OSError(f"Could not save screenshot to {OUTPUT}")
if not OUTPUT.is_file() or OUTPUT.stat().st_size == 0:
raise OSError(f"Screenshot is missing or empty: {OUTPUT}")
print(f"Saved {OUTPUT.resolve()}")
finally:
driver.quit()
The timeout and viewport are starting points, not guarantees for every portal or machine. Use a condition that means the screenshot will be useful. For example, visibility of the result heading is stronger than merely waiting for an element to exist. If the portal reveals results only after a permitted action, perform that action through the documented interface and wait for the resulting panel; do not use automation to evade a control.
3. Choose a wait condition that matches the result
Selenium navigation waits for a configured document readiness state. A page can still update afterward as JavaScript fetches and renders content. The Selenium waiting guide recommends waiting for a specific condition when later page state matters. Selenium waiting strategies
| What must be ready | Example condition | When it helps |
|---|---|---|
| Result element exists in the DOM | presence_of_element_located |
Useful if the element may exist before it is visible; by itself it may capture a hidden or loading panel. |
| Result panel is on screen | visibility_of_element_located |
Good default for a screenshot of visible content. |
| A specific result state is shown | text_to_be_present_in_element |
Use when the portal displays a known published, loaded, or empty-results message. |
| Several result rows are present | Wait for a portal-specific row locator or count | Useful when the panel appears before its data has populated. |
Selenium documents expected conditions for element existence, visibility, and visible text. Choose a selector and state that reflect the actual portal. Avoid mixing implicit and explicit waits: Selenium warns that doing so can produce unpredictable wait durations. Wait documentation · Expected conditions API
4. Current-window or full-page screenshot?
driver.save_screenshot() captures the current window. Content below the visible area may not be included, so inspect the PNG for clipped columns, overlays, or missing rows. Set a deliberate window size when layout matters, especially in headless mode. Selenium’s screenshot guide includes a headless Chrome example. Selenium screenshot guide
For a long result table or transcript, a full-document capture may be more appropriate. The current Python Firefox WebDriver API exposes save_full_page_screenshot and get_full_page_screenshot_as_png. This is a Firefox-specific API; do not assume the same method exists for every browser driver. Check the API for the Firefox driver version you use. Selenium Firefox WebDriver API
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options)
try:
driver.get("OFFICIAL_RESULTS_PAGE_URL")
# Wait for the portal-specific result condition before this call.
driver.save_full_page_screenshot("university_results_full.png")
finally:
driver.quit()
Add the same explicit wait from the main example before taking the Firefox full-page capture. A very tall image can be difficult to read or share; consider whether the visible result section alone answers the need.
5. Run headless or inspect the browser
Headless mode is useful in a non-interactive environment. For initial setup, visible mode makes it easier to inspect redirects, the page state, and whether the selector matches. Selenium’s browser options include page-load strategies such as normal, eager, and none, but changing navigation readiness does not replace waiting for the result condition. Selenium browser options
If you change the page-load strategy, keep an explicit wait for the result state. A faster navigation return is not proof that the screenshot will contain final result data.
6. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Screenshot shows a spinner or blank results panel | Navigation returned before asynchronous content rendered, or the wait condition is too weak. | Wait for a visible result heading, populated table row, or portal-specific ready message. Increase the explicit timeout if normal rendering takes longer. |
TimeoutException |
The selector is wrong, the element is not visible, the result is not published, or the page did not reach that state in time. | Inspect the authorized page in a regular browser, verify the selector and expected state, then adjust the timeout to a reasonable value. Do not guess a university-specific selector. |
InvalidSelectorException |
The CSS selector is malformed or uses syntax unsupported by the browser. | Test and correct the selector against the page DOM. Prefer a stable result container or heading. |
| Columns or rows are cut off | The current-window screenshot does not include the whole document, or the viewport is too narrow. | Set a suitable window size; for long pages consider Firefox’s documented full-page screenshot method and inspect readability. |
| Browser or driver fails to start | Browser installation, permissions, or environment setup may be incomplete. | Install a supported browser, update Selenium, review the browser startup error, and try visible mode to diagnose environment issues. |
| PNG is absent or empty | Output path is not writable, screenshot saving failed, or the script ended before checking the file. | Use a writable absolute path, check the boolean return value, and verify that the file exists and has nonzero size. |
| Screenshot contains an error or access page | The portal returned an error or an access policy prevented the requested view. | Use the official portal and follow its stated access process. Do not try to bypass CAPTCHA, bot checks, or other controls. |
7. Reliability, privacy, and cost
- Reliability: wait for the exact visible state you need, use a stable locator, set a page-load timeout, and always close the driver in a
finallyblock. - Review: check the saved image for loading indicators, error states, clipped content, and legibility. That verification is part of the workflow; a successful file write alone does not prove the page was ready.
- Privacy: student result pages can contain personal information. Keep screenshots private, redact identifiers before sharing, and follow the institution’s rules.
- Cost: Selenium and the browser run in your environment; account for the compute and maintenance needed to install and run them. This guide makes no benchmark or cost estimate.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. Its one-request API returns an image or PDF; see the ScreenshotNeo API documentation for request options. Use it only for a results page you are authorized to access.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
Replace the sample target URL with the official results URL you are authorized to capture. Cookie banners, newsletter popups, and chat widgets are removed before the shot, and each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers identify the page verdict and billing status. An MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Every feature is on every plan. Learn more at ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.
FAQ
How do I take a screenshot with Selenium Python?
Wait for the result state you need, then call driver.save_screenshot("file.png"). Check the return value and inspect the saved image.
How do I capture a full page screenshot in Selenium?
The standard Python save_screenshot method captures the current window. Python Firefox WebDriver documents separate full-page screenshot methods; use one only with a compatible Firefox driver.
How do I wait for a result page to load in Selenium?
Use WebDriverWait with a condition tied to the actual result, such as visibility of its heading or a known result message. Page readiness alone may not include JavaScript-rendered data.
What selector should I use for an Indian university results page?
There is no single selector for Indian university portals. Inspect the specific official page you are authorized to access and choose a stable locator from its DOM.
Can this workflow retrieve results behind a portal control?
Use the portal’s official access process and follow its terms. This guide does not provide a way to bypass access controls.


