What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
In Python, call driver.get_screenshot_as_base64() on an active Selenium WebDriver session. It returns a Base64-encoded screenshot string—not PNG bytes and not an HTML data URL. Add the data:image/png;base64, prefix only if the next step needs an image source for HTML.
Return the screenshot as Base64 text in Python
Navigate to the page, call Selenium’s Base64 screenshot method, then pass the returned string to the code that needs it. This example uses Chrome:
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
screenshot_b64 = driver.get_screenshot_as_base64()
# screenshot_b64 is a Base64-encoded string
finally:
driver.quit()
Remove the extra leading spaces before driver in the code above if copying it as a top-level Python script; the runnable version is:
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
screenshot_b64 = driver.get_screenshot_as_base64()
# screenshot_b64 is a Base64-encoded string
finally:
driver.quit()
The method captures the current window screenshot. Selenium’s Python API documents its return type as str. See the Python WebDriver API.
Recommended Free Tools
#1 Best Overall
Choose the output format your next step needs
| Needed output | Python method | What you receive | Use it for |
|---|---|---|---|
| Base64 text | driver.get_screenshot_as_base64() |
A Base64-encoded str |
Transporting or embedding the encoded screenshot |
| PNG bytes | driver.get_screenshot_as_png() |
Decoded PNG bytes |
In-memory image processing or writing bytes yourself |
| PNG file | driver.save_screenshot("screenshot.png") |
Saves a PNG and returns a Boolean success value | Saving directly to a path |
| Element screenshot | Use the relevant element screenshot API for your binding | Screenshot for the selected element, where supported | Capturing one element instead of the driver’s current window |
Selenium’s WebDriver screenshot response is Base64-encoded. Don’t decode the result if the consumer expects Base64 text. Decode only when the next operation expects raw image bytes. API names and return types vary across language bindings; check the relevant binding’s documentation.
Embed the Base64 string in HTML
An HTML image source needs a data URL, which consists of the image MIME type prefix followed by the Base64 payload:
Rank #2
img_src = f"data:image/png;base64,{screenshot_b64}"
Use that value as an image’s src. The prefix identifies the content as a PNG data URL; the Base64 string by itself is not a complete data URL.
Capture scope: current window or element
The Python driver method is documented as a screenshot of the current window. Do not assume it captures an arbitrarily long, full-page document across all browsers and implementations. If you need a particular element, use the element-level screenshot API documented for your binding. Selenium’s Java reference describes screenshot scope and best-effort behavior for nonconformant implementations; verify the result in your target browser and binding.
Rank #3
Other Selenium language bindings
| Binding | Documented call | Result |
|---|---|---|
| Python | driver.get_screenshot_as_base64() |
Base64 str |
| Java | ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64) |
Base64 string |
| JavaScript | await driver.takeScreenshot() |
Encoded string |
Selenium’s official documentation shows the JavaScript screenshot method and writing the result using a Base64 encoding argument. The Java API reference describes TakesScreenshot and OutputType.BASE64. Consult the API reference for the specific language and version you use.
Troubleshoot common problems
- You got a string, but the image consumer rejects it: Check whether it expects Base64 text, raw PNG bytes, or a data URL. Add
data:image/png;base64,only for an HTML image source. - You decoded the text and now need Base64: Keep the original value from
get_screenshot_as_base64(); useget_screenshot_as_png()only when raw PNG bytes are needed. - The result shows only the visible window, not the whole document: The driver method is documented for the current window. Use an appropriate full-page approach for your browser and verify its behavior; don’t assume the standard call captures an arbitrarily long page.
- You need only one component of the page: Use the element screenshot API where available rather than treating the driver screenshot as an element capture.
- The browser session is unavailable: The call requires an active WebDriver session. Ensure navigation and screenshot capture happen before calling
driver.quit().
Or skip the browser setup
ScreenshotNeo returns a screenshot or PDF from one GET request, without setting up a Selenium browser session. Its clean-shot steps can accept cookie banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents.
For example, this cURL request saves a WebP screenshot:
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo documentation for request options and response details. It includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Frequently Asked Questions
Does get_screenshot_as_base64() return a data URL?
No. It returns Base64 text. To use it as an HTML image source, prefix it with data:image/png;base64,.
Best Value
Do I need to decode the result before sending it to an API?
Only if that API expects raw PNG bytes. If it expects a Base64 string, send the returned string as-is.
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.




