Last verified: 2026-02-20 · Source
Cross-browser screenshots for Selenium tests
Add API-based screenshot capture to Selenium test suites. Create baseline screenshots for visual regression testing across Chrome, Firefox, Safari, and Edge.
Selenium + Scrnpix Baseline Capture
Capture consistent baselines before running cross-browser Selenium tests:
curl "https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1366&height=768&full_page=true" \ -H "X-KEY: your-api-key" \ -o selenium-baseline.png
CI Response Handling
Handle API responses in your Selenium test suite:
| Status | Description |
|---|---|
| 200 OK | Success. Python: response.content contains bytes. Java: response.body().bytes() for image data. |
| 400 Bad Request | Invalid parameters. Check URL encoding and numeric values. Assert response before saving. |
| 401 Unauthorized | API key error. Python: os.environ['API_KEY']. Java: System.getenv(). Verify CI secrets. |
| 408 Timeout | Page load timeout. Target may be slow. Implement retry with tenacity (Python) or Failsafe (Java). |
| 5xx Server Error | Transient failure. Use @retry decorator (Python) or try-catch with loop (Java) for resilience. |
Key Features
Cross-Browser Baselines
Use Scrnpix to generate consistent baseline screenshots. Compare against Selenium's screenshots across Chrome, Firefox, Safari, Edge.
Grid Compatible
Works with Selenium Grid and cloud providers like BrowserStack/Sauce Labs. Use Scrnpix for baselines, Grid for live test screenshots.
Python & Java Support
Integrate via Python requests or Java HttpClient. Fits naturally into existing Selenium test frameworks like pytest or JUnit.
CI/CD Optimization
Reduce CI time by generating baselines via API instead of spinning up WebDriver instances. Use WebDriver only for actual test execution.
Frequently Asked Questions
How do I integrate Scrnpix with Selenium tests?
Use HTTP client libraries (Python requests, Java HttpClient) to call Scrnpix API in test setup. Capture baseline screenshots before running WebDriver tests.
Can I use this with existing visual testing tools?
Yes. Use Scrnpix for baseline generation, then use tools like Ashot (Java) or selenium-screenshot (Python) for comparison in tests.
How do I handle cross-browser rendering differences?
Scrnpix uses Chromium for consistent baselines. Compare against browser-specific Selenium screenshots to detect rendering differences across browsers.
Does this work with Selenium Grid?
Yes. Scrnpix runs independently of Grid. Use it for baseline generation, use Grid for executing browser tests and capturing live screenshots.
Add visual testing to Selenium
Capture baseline screenshots via API and integrate with your Selenium test suite. Works with Grid, cloud providers, and CI/CD.
Start Testing