Add comprehensive tests and docs for darkMode & hideSelectors
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled

- Add 5 new Python tests for darkMode and hideSelectors parameters
- Update Node.js SDK README with darkMode/hideSelectors examples
- Update Python SDK README with darkMode/hideSelectors examples
- Add API reference entries for new parameters
- All tests passing: Node.js (19 tests), Python (22 tests)

Features already implemented in v0.7.0 but needed better test coverage and documentation.
This commit is contained in:
Hoid (OpenClaw) 2026-03-04 18:04:18 +01:00
parent 28f4a93dc3
commit e6c34ef760
3 changed files with 214 additions and 0 deletions

View file

@ -75,6 +75,52 @@ screenshot = snap.capture(
)
```
### Dark Mode Capture
```python
# Capture in dark mode (prefers-color-scheme: dark)
dark_screenshot = snap.capture(
"https://example.com",
dark_mode=True,
format="png",
)
```
### Hide Elements Before Capture
```python
# Hide cookie banners, popups, ads
clean_screenshot = snap.capture(
"https://example.com",
hide_selectors=[
".cookie-banner",
".popup-overlay",
"#advertisement",
".tracking-notice"
],
)
# Hide single element
single_hide = snap.capture(
"https://example.com",
hide_selectors=".newsletter-popup",
)
```
### Combined Dark Mode + Element Hiding
```python
# Perfect for clean marketing screenshots
marketing_shot = snap.capture(
"https://your-saas-app.com",
dark_mode=True,
hide_selectors=[".dev-banner", ".beta-notice"],
width=1920,
height=1080,
device_scale=2,
)
```
### Error Handling
```python
@ -106,6 +152,8 @@ except SnapAPIError as e:
| `device_scale` | `float` | `1` | Device pixel ratio (13) |
| `delay` | `int` | `0` | Extra delay in ms (05000) |
| `wait_until` | `str` | `"domcontentloaded"` | Load event |
| `dark_mode` | `bool` | `False` | Emulate prefers-color-scheme: dark |
| `hide_selectors` | `list` | — | CSS selectors to hide before capture |
### `snap.health() -> dict`