Add comprehensive tests and docs for darkMode & hideSelectors
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
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:
parent
28f4a93dc3
commit
e6c34ef760
3 changed files with 214 additions and 0 deletions
|
|
@ -72,6 +72,51 @@ const screenshot = await snap.capture({
|
|||
});
|
||||
```
|
||||
|
||||
### Dark Mode Capture
|
||||
|
||||
```typescript
|
||||
// Capture in dark mode (prefers-color-scheme: dark)
|
||||
const darkScreenshot = await snap.capture({
|
||||
url: 'https://example.com',
|
||||
darkMode: true,
|
||||
format: 'png',
|
||||
});
|
||||
```
|
||||
|
||||
### Hide Elements Before Capture
|
||||
|
||||
```typescript
|
||||
// Hide cookie banners, popups, ads
|
||||
const cleanScreenshot = await snap.capture({
|
||||
url: 'https://example.com',
|
||||
hideSelectors: [
|
||||
'.cookie-banner',
|
||||
'.popup-overlay',
|
||||
'#advertisement',
|
||||
'.tracking-notice'
|
||||
],
|
||||
});
|
||||
|
||||
// Hide single element
|
||||
const singleHide = await snap.capture('https://example.com', {
|
||||
hideSelectors: '.newsletter-popup',
|
||||
});
|
||||
```
|
||||
|
||||
### Combined Dark Mode + Element Hiding
|
||||
|
||||
```typescript
|
||||
// Perfect for clean marketing screenshots
|
||||
const marketingShot = await snap.capture({
|
||||
url: 'https://your-saas-app.com',
|
||||
darkMode: true,
|
||||
hideSelectors: ['.dev-banner', '.beta-notice'],
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
deviceScale: 2,
|
||||
});
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
### `new SnapAPI(apiKey, config?)`
|
||||
|
|
@ -98,6 +143,8 @@ Returns a `Promise<Buffer>` containing the screenshot image.
|
|||
| `deviceScale` | `number` | `1` | Device pixel ratio (1–3) |
|
||||
| `delay` | `number` | `0` | Extra delay in ms (0–5000) |
|
||||
| `waitUntil` | `string` | `'domcontentloaded'` | Load event to wait for |
|
||||
| `darkMode` | `boolean` | `false` | Emulate prefers-color-scheme: dark |
|
||||
| `hideSelectors` | `string \| string[]` | — | CSS selectors to hide before capture |
|
||||
|
||||
### `snap.health()`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue