Use the screenshot keyword that matches what you need to capture: Robot Framework’s built-in Screenshot library captures the test machine’s desktop, SeleniumLibrary captures a Selenium page or element, and the Playwright-based Browser library captures a viewport, element, or full scrollable page. The examples below show complete Robot files, artifact-path behavior, display requirements, CI fixes, and a browser-free API option.
Choose the capture method first
Your existing test stack and the target determine the right keyword. Desktop capture includes everything visible on the runner, while browser-library keywords capture content inside an automated browser.
| What you need | Library and keyword | Important behavior |
|---|---|---|
| Entire desktop or a native application | Screenshot — Take Screenshot |
Needs a physical or virtual display and a supported capture backend. |
| Current page in Selenium | SeleniumLibrary — Capture Page Screenshot |
Saves an image and embeds it in the Robot log by default. |
| One Selenium element | SeleniumLibrary — Capture Element Screenshot |
Element capture support differs between browser vendors and drivers. |
| Viewport or element in Browser | Browser — Take Screenshot |
Use a selector for an element. |
| Full scrollable page in Browser | Browser — Take Screenshot fullPage=True |
Playwright scrolls and stitches the page. |
Capture the desktop with Robot Framework’s Screenshot library
This is the correct choice for a desktop application, a native dialog, or a failure where you need to see the entire runner. The image is JPEG and is embedded in the log by default.
Minimal test
*** Settings ***
Library Screenshot
*** Test Cases ***
Capture Desktop
Take Screenshot
Run it with robot tests/. The file is written to the log directory, or to the output directory when no log is generated. The keyword also places the image in the Robot log, making it available when you open log.html.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
Name the file and control embedding
*** Settings ***
Library Screenshot
*** Test Cases ***
Named Desktop Capture
Take Screenshot artifacts/login-screen.jpg 800px
Take Screenshot Without Embedding artifacts/after-submit.jpg
The optional width controls the embedded image’s display width in the log. Take Screenshot Without Embedding leaves a separate file linked from the log instead of placing the image data inside it. If you repeat a name without a .jpg or .jpeg extension, the library adds a unique index so earlier captures are not overwritten.
Set a screenshot directory
Pass screenshot_directory when importing the library or set it during the test:
*** Settings ***
Library Screenshot screenshot_directory=${EXECDIR}${/}artifacts
*** Test Cases ***
Capture To Artifacts
Set Screenshot Directory ${EXECDIR}${/}artifacts
Take Screenshot desktop-failure.jpg
The directory must already exist when using the built-in keyword. Create it in your CI job or before the suite starts; otherwise the capture can fail even though the test itself is valid.
Display and operating-system requirements
A desktop screenshot is not a browser screenshot. The runner must have a physical or virtual display. On macOS, the library uses the system screencapture utility. Other operating systems may need a supported tool or module, such as wxPython, PyGTK, Pillow (Windows), or scrot (not Windows). If you do not specify a backend, the library uses the first supported option it finds.
Recommended Free Tools
Headless Linux containers normally have no display. Run the suite inside a virtual display arrangement, or use a browser-library screenshot when only the web page is relevant. A virtual display must be started before Robot Framework and remain available to the test process.
Rank #2
Capture a page or element with SeleniumLibrary
Use SeleniumLibrary when the test already controls a browser through Selenium. Page screenshots represent the browser page, not the whole operating-system desktop.
Capture the current page
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Capture Browser Page
Open Browser https://example.com chrome
Capture Page Screenshot
Close Browser
With no filename, SeleniumLibrary chooses a name and saves the image in the log directory while embedding it in the log. Supply a filename to choose the artifact location. Include {index} when a test captures the same logical name repeatedly:
*** Test Cases ***
Capture Several States
Open Browser https://example.com chrome
Capture Page Screenshot ${EXECDIR}${/}artifacts${/}state-{index}.png
Click Element css:button
Capture Page Screenshot ${EXECDIR}${/}artifacts${/}state-{index}.png
Close Browser
Use an artifact directory collected by your CI system rather than a temporary workspace that is deleted after the job.
Capture one element
*** Test Cases ***
Capture Main Content
Open Browser https://example.com chrome
Capture Element Screenshot css:main
Close Browser
The argument is any locator accepted by SeleniumLibrary, such as css:main, id:checkout, or an XPath locator. Element screenshots have limited support among browser vendors, so a failure may be a driver/browser limitation rather than a bad locator. Try a page screenshot to confirm that the browser session itself is healthy, then verify the target browser and driver combination.
Make Selenium captures useful in failures
Capture after the state you want to diagnose: after navigation has completed, after a modal opens, or immediately before a potentially failing assertion. For teardown diagnostics, keep the browser open until the capture runs and close it afterward. If a test can fail before the capture keyword, place a failure hook or a teardown keyword that checks whether a browser is still active.
Rank #3
Capture with Robot Framework Browser (Playwright)
The Browser library uses Playwright. Its Take Screenshot keyword captures the current viewport by default and can target an element or the complete scrollable page.
Full-page example
*** Settings ***
Library Browser
*** Test Cases ***
Capture Full Page
New Page https://example.com
Take Screenshot fullPage=True fileType=png
Viewport and element captures
*** Test Cases ***
Capture Viewport And Card
New Page https://example.com
Take Screenshot fileType=jpeg
Take Screenshot selector=css:main .pricing-card fileType=png
Browser supports PNG and JPEG, embedding in the HTML log, choosing a path, or returning image data. Argument names and defaults can evolve with the installed Browser version, so check that version’s keyword documentation when you add options such as path, quality, or image-data return values.
Understand the default directory
Browser uses ${OUTPUTDIR}/browser/screenshot by default. Its documentation states that ${OUTPUTDIR}/browser/ is removed at the first suite startup. Do not store long-lived CI evidence there without copying it to a retained artifact directory. Give an explicit path when another process collects screenshots from a fixed location.
Keep screenshots reliable in CI
Wait for the state you intend to record
A screenshot taken during navigation can show a loading shell rather than the completed page. Wait for a page-specific element, a visible status, or a stable application state before capturing. For full pages, ensure lazy-loaded content has had time to render; otherwise the image can legitimately omit content that has not entered the viewport.
Use deterministic names and directories
- Create the directory before the test starts.
- Include suite, test, browser, and an index or timestamp in names when parallel jobs share storage.
- Configure CI to upload PNG/JPEG files and Robot’s
log.htmltogether. - Keep screenshots outside ephemeral directories that are cleaned at suite startup.
Choose embedding deliberately
Embedded images make a single log convenient but can make the HTML large. Use the “without embedding” keyword or an explicit artifact path when a suite captures many high-resolution images.
Rank #4
Troubleshooting common failures
“No screenshot tool” or a blank desktop image
The runner probably has no supported backend or no display. Install a supported module/tool for that operating system and provide a physical or virtual display. In a headless container, start the virtual display before Robot Framework. If you only need a web page, switch to SeleniumLibrary or Browser instead of desktop capture.
Free tools Windows power users keep installed
One-click scans. No signup required.
Directory or permission errors
The destination does not exist or the test user cannot write it. Create the directory in the job setup, use an absolute path such as ${EXECDIR}${/}artifacts, and verify ownership and permissions. For the Screenshot library, remember that a custom screenshot directory must already exist.
Element screenshot fails while page screenshot works
Check the locator and wait for the element to be present and visible. If those are correct, the browser/driver may not implement element screenshots consistently. Use a page screenshot with a narrowed viewport or verify support for the exact vendor combination.
Browser screenshot is too short
The default is the current viewport. Add fullPage=True for the complete scrollable page. If content is loaded lazily, wait for the application to finish loading it before capture.
Images disappear between runs
Browser’s default ${OUTPUTDIR}/browser/ directory is removed at first suite startup. Select a retained artifact path and configure the CI collector to upload it after every run.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsBest Value
Log becomes extremely large
High-resolution embedded images accumulate quickly. Capture only at useful checkpoints and use Take Screenshot Without Embedding for desktop captures, or explicit external paths and artifact upload for browser captures.
Or skip the browser setup
For server-side page images, ScreenshotNeo returns a screenshot from one GET request, without managing Selenium, Playwright, drivers, or a display. It accepts PNG, JPEG, or WebP output and can also create PDFs. See the ScreenshotNeo documentation for all parameters.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and whether it was billed. 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 without a card; paid plans start at $5 for 3,000 screenshots. Sign up for the free ScreenshotNeo plan.
When to use each approach
- Choose
Screenshotfor native applications, desktop dialogs, or evidence of the complete runner. - Choose SeleniumLibrary for a Selenium test that needs page or element images.
- Choose Browser for Playwright-backed viewport, element, and full-page captures.
- Choose ScreenshotNeo when a URL screenshot should run as an API request or through an AI-agent MCP client instead of a locally managed browser.
Frequently Asked Questions
Does Robot Framework screenshot capture require a visible monitor?
Desktop capture with the Screenshot library requires a physical or virtual display. Browser-library screenshots run inside the automated browser, but still need the browser runtime configured for the chosen library.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated 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 matchWhich keyword captures a full page rather than only the viewport?
In Robot Framework Browser, use Take Screenshot with fullPage=True. SeleniumLibrary’s Capture Page Screenshot captures the page available through its Selenium implementation; verify the behavior needed for your browser and driver.
Can I save screenshots outside the Robot log?
Yes. Use Take Screenshot Without Embedding for the built-in library, or provide an explicit filename/path with SeleniumLibrary and Browser. Store the files in a CI directory that is uploaded after the run.
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.

