How to use LambdaTest Screenshot with Selenium for cross-browser screenshots
Capture screenshots during Selenium tests, retrieve LambdaTest session artifacts, or run a URL across a browser matrix. Choose the workflow that fits your goal.
To take a screenshot during a Selenium test on LambdaTest, navigate to the page, wait for the state you want to record, then call your Selenium language binding’s screenshot method. That captures the current browsing context. To get screenshots from a completed LambdaTest session, retrieve its step screenshots through the session screenshot endpoint. To capture a URL across many browser and operating system combinations, use LambdaTest’s separate Automated Screenshot API. For visual regression against a baseline, use SmartUI snapshots.
These are three different workflows. Pick one based on whether you need an image at a point in a test, a browser matrix of URL screenshots, or a comparison of named snapshots across builds. Current vendor documentation also uses TestMu AI branding; this guide keeps the familiar LambdaTest name used in the title.
1. Choose the screenshot workflow
| Need | Use | What you receive |
|---|---|---|
| Capture the page state reached by Selenium interactions | Selenium WebDriver screenshot method | Image data or a local PNG, depending on the language binding |
| Download screenshots recorded during a completed LambdaTest Selenium session | LambdaTest session screenshot endpoint | A URL for a ZIP of step-by-step screenshots |
| Capture a URL across configured browsers, versions, operating systems, and resolutions | Automated Screenshot API | A test ID and per-configuration screenshot records and URLs |
| Compare named snapshots against a baseline across builds | SmartUI Selenium SDK | Build and mismatch results in a SmartUI project |
A WebDriver screenshot is tied to the current browsing context and test state. Do not assume ordinary WebDriver capture is full-page in every browser and binding. The Automated Screenshot API is the documented URL-driven route for full-page screenshots.
2. Capture a screenshot during a Selenium test
Use Selenium’s screenshot method after navigation and after the page has reached the state you intend to preserve. The following Python example saves the current view as a PNG. It assumes Selenium and a browser driver are installed and configured for your environment; on LambdaTest, configure your remote WebDriver session with the credentials and capabilities from your account and the current Selenium setup documentation.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
# Add the remote endpoint and LambdaTest capabilities for your account here.
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
)
driver.save_screenshot("page.png")
finally:
driver.quit()
For a remote LambdaTest session, use your remote WebDriver endpoint and the desired browser, operating system, and version capabilities in place of the local driver construction above. Keep credentials out of source control. The screenshot call remains part of the Selenium workflow: it records the browser state at the moment the call runs.
Capture timing and output
- Wait for a meaningful state, such as a result element becoming visible, rather than relying only on a fixed sleep.
- Capture after the relevant interactions, including form submission, navigation, or opening a menu.
- Selenium language bindings can save an image to a PNG path or return screenshot data. Check the binding’s method and return type before treating it as a file or base64 string.
- Close the driver in a
finallyblock or equivalent cleanup so failed assertions do not leave sessions running. - Do not promise full-page output from ordinary WebDriver capture without checking the browser and binding behavior you target.
3. Retrieve screenshots from a LambdaTest Selenium session
If the Selenium test has already run on LambdaTest and you need its recorded step screenshots, retrieve them by session ID through the official session screenshot endpoint. This is artifact retrieval; it does not drive the browser or decide which page states Selenium captures.
The endpoint uses Basic authentication and returns a URL for the step-by-step screenshots in ZIP format. Store the session identifier from the test result, then call the endpoint with your LambdaTest username and access key. The precise host and path are account and documentation details; use the current official session API documentation rather than guessing an endpoint.
4. Capture a URL across a browser matrix with the Screenshot API
Use the Automated Screenshot API when the input is a URL and the output should cover multiple operating systems, browsers, versions, or resolutions. The API accepts a POST request with the target URL, screen resolution fields, and a configs matrix. It supports full-page screenshots. Obtain supported combinations and resolutions from the vendor’s discovery endpoints; documentation examples may contain old versions and are not a live compatibility list.
Prepare credentials and discover configurations
- Set your LambdaTest username and access key as environment variables. The API uses Basic authorization.
- Query the official endpoints for supported OS/browser/version combinations and resolutions.
- Select the combinations that matter to your users and include them in the request’s
configsarray. - Submit the screenshot request and save the returned test ID.
- Poll or retrieve the result using that ID, then use each screenshot record to identify its OS, browser, browser version, status, resolution, screenshot URL, and thumbnail URL.
The request shape is shown below. The values for endpoint paths and configuration fields must follow the current official Automated Screenshot API documentation. This template deliberately does not invent a URL or exact schema beyond the fields established by that documentation.
curl --request POST "$LAMBDATEST_SCREENSHOT_ENDPOINT" \
--user "$LT_USERNAME:$LT_ACCESS_KEY" \
--header 'Content-Type: application/json' \
--data '{
"url": "https://example.com",
"configs": [
{
"platform": "<discovered operating system>",
"browser": "<discovered browser>",
"browser_version": "<discovered version>"
}
],
"resolution": "<discovered resolution>"
}'
Use the exact property names and accepted resolution format from the current API reference. The placeholders above are not literal supported values.
Poll or fetch results
After starting the run, retain its test ID. Use the documented result endpoint for that ID. The result includes the test status and requested URL, plus records for each screenshot configuration. Check the individual status before consuming an image URL; a matrix run can have a result per configuration.
Optional API settings and edge cases
| Situation | Configuration | What to check |
|---|---|---|
| Target is served from a local development environment | Set "tunnel": true in the request configuration as documented |
Confirm the tunnel is available to the cloud run and the local app is listening. |
| Target is protected by HTTP Basic Authentication | Provide the page’s username and password fields in the request |
Keep credentials secret and verify the page can load after authentication. |
| Results need to be sent to another system | Provide the callback URL field shown in the guide | Use the exact documented field and make sure the receiving endpoint can accept the callback. |
| Run is still in progress and should be stopped | Use the documented PUT stop operation | Stopping an already completed session returns 404, according to the guide. |
| Browser or version is unavailable | Refresh the matrix from the supported-combinations endpoint | Do not rely on old example versions copied from a guide. |
5. Use SmartUI for visual regression
If the goal is detecting visual changes across builds, use the SmartUI Selenium SDK rather than treating an isolated screenshot as a comparison. The Java guide describes creating a SmartUI project, configuring browser and viewport settings, navigating with Selenium, and taking a named snapshot:
SmartUISnapshot.smartuiSnapshot(driver, "Homepage");
Use a stable snapshot name so a new build can match the corresponding baseline. SmartUI’s guide also describes selectors for including or excluding dynamic DOM content from comparison. Those are SmartUI capabilities; they are not options on Selenium’s ordinary screenshot method. Verify the current supported browser matrix before configuring it.
6. Make cross-browser screenshots useful
- Choose representative configurations. Query the live matrix, then select OS, browser, version, and resolution combinations that reflect the users or defects you need to cover.
- Stabilize the page state. Wait for the exact content or control that signals readiness. Dynamic content, animations, delayed assets, and personalized data can make two captures differ even when the layout is unchanged.
- Separate capture from comparison. Use WebDriver screenshots to preserve a test state, the Screenshot API to fan a URL out across configurations, and SmartUI when baseline comparison is the desired result.
- Record configuration with the image. Keep the test ID and each result’s OS, browser, version, resolution, status, and activity ID with the artifact.
- Keep access data out of logs. Store API credentials as environment variables or in your secret manager, and avoid printing authenticated request details.
- Use deliberate cleanup. Close Selenium sessions and stop only API jobs that are still running and no longer needed.
7. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The screenshot shows a loading state or incomplete page | The capture ran before the intended content was ready | Wait for a specific element or state before calling the screenshot method. |
| The ordinary Selenium screenshot does not include the whole page | WebDriver capture behavior depends on the browser and binding; it is not universally full-page | Check the target binding and browser, or use the Automated Screenshot API for its documented full-page URL capture. |
| The API rejects authentication | Incorrect username/access key, missing Basic auth, or malformed environment variables | Set the credentials correctly and pass them using the documented Basic authorization method. |
| A requested browser configuration fails | The matrix contains an unsupported or outdated OS/browser/version combination | Query the current supported-combinations endpoint and rebuild the matrix. |
| A local application cannot be reached | The cloud run cannot access the developer’s local network | Use the documented tunnel option and check that the app and tunnel are running. |
| A protected page shows an authentication prompt | The API request did not include the documented Basic Auth page credentials or they are wrong | Supply the page’s username and password fields and confirm them against the target. |
| The stop request returns 404 | The screenshot session has already completed | Read the result endpoint; completed sessions cannot be stopped through that operation. |
| A result has no usable screenshot | The per-configuration run may have failed or not completed | Inspect the overall test status and the individual screenshot record status before using its URL. |
| Visual regression reports noisy differences | Dynamic DOM content changes between builds | Use SmartUI’s documented include/exclude selectors for volatile content and keep the snapshot name stable. |
| Images differ across runs unexpectedly | Different page state, viewport, browser version, or content timing | Compare the recorded configuration and resolution, then make the page state deterministic before capture. |
8. Performance, reliability, and cost considerations
A Selenium screenshot adds work to the test at the point of capture, while a matrix API run creates work for each requested configuration. Keep the matrix focused on combinations that answer a real compatibility question, and fetch results by test ID instead of resubmitting runs when you only need to inspect status or artifacts.
For reliable output, treat readiness and configuration as part of the capture contract: wait for a stable state, record the browser and resolution, and check each configuration’s status. Cloud browser availability and supported versions can change, so discover the live matrix when configuring a run. The supplied documentation does not establish a universal runtime, success rate, or price for these workflows; consult current vendor account and pricing information for cost planning.
9. FAQ
Does a Selenium screenshot automatically run across multiple browsers?
No. A WebDriver screenshot records the current session. To capture a URL across a matrix, submit a separate Automated Screenshot API run or create multiple Selenium sessions.
Does retrieving a session ZIP take the screenshot?
No. Selenium determines when screenshots are taken during the test. The session endpoint retrieves the recorded step screenshots afterward.
When should I choose SmartUI?
Choose it when you need named snapshots compared with a baseline across builds. For a one-time image, use Selenium or the Screenshot API workflow that matches your input.
Or skip the browser setup
For a URL screenshot without configuring a browser session or a cross-browser matrix, ScreenshotNeo provides a single GET request. Cookie banners are accepted and removed before capture, and known consent platforms, newsletter popups, and chat widgets are removed; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
One thousand screenshots a month are free with no card. Paid plans start at $5 for 3,000 screenshots, and every feature is on every plan. See the ScreenshotNeo API documentation for the request options.
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}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. Sign up for 1,000 free screenshots a month with no card.


