snapscreenshot: true
snap
snap
snaproute | "/docs/"index.*main.*README.*"/docs/""/docs/index""/docs/README""/" | ||
screenshot | |||
full_page | |||
selector | |||
device | "mobile""tablet""laptop""desktop""tablet-landscape" | ||
width | |||
height | |||
dark | lightprint | ||
light | darkprint | ||
print | darklight | ||
measure | |||
tokens | token_prefix | ||
token_prefix | tokens["text", "heading", "surface"]"color" | ||
palette | |||
assert | >=<===!=><~=["css(stencila-paragraph).fontSize>=16px"] | ||
wait_for | |||
delay | |||
resize | "never""auto""optimize" | ||
max_image_dimension | "auto""optimize" |
The /_specimen route
/_specimen/_specimen
User pages
route: "/"route: "/docs/"route: "/guide/install/"docs/README.mddocs/main.mddocs/index.md"/docs/"/_specimen
Measurement presets
auto | |
document | |
site | |
all | |
header | |
nav | |
main | |
footer | |
theme |
measure
theme
Output fields
selector_matched— whether the target selector was found on the page (present even without a screenshot) measurements — per-element computed styles when a measurepreset is active dom_context— DOM structural context for each measured element (see DOM context below) tokens — resolved CSS custom property values grouped by family (when tokens: true) palette — extracted color palette (when palette: true) assertions — pass/fail results for each assertion expression diagnostics — informational messages (e.g. unmatched selectors on the route — these are route facts, not theme bugs)
DOM context
measuredom_contextcssbox_infotextcounts
Structure
dom_context
tagName | "stencila-paragraph""header""div" | |
id | ||
classes | ||
schemaAncestors | ancestors"Article.ListItem" | |
schemaDepth | depth | |
domAncestors | <body>tagidclassesbodyElement.parentElement |
Stability expectations
summariescontrastcountsdom_contexttextcssbox_infodiagnosticserrors{}[]dom_context
Tag names, IDs, and classes reflect the live DOM at measurement time. Frontend refactors may change these values. Stencila schema attributes ( schemaAncestors, schemaDepth) are more stable because they derive from the document schema, but may evolve with schema changes. Ancestor chain length and structure depend on the page's HTML structure, which varies between routes, layout presets, and Stencila versions.
Examples
# Measurement-only baseline — no screenshot (default behavior)
# Extract specific token families to verify they took effect
snap(route: "/_specimen", tokens: true, token_prefix: ["text", "heading", "surface"])
# Verify specific token families resolved correctly
snap(route: "/_specimen", tokens: true, token_prefix: ["font", "heading", "line-height"])
# Holistic layout review with the theme measurement preset
# Returns summaries and diagnostics first, then verbose CSS details
snap(route: "/_specimen", measure: "theme")
# Site chrome review (header, nav, footer)
snap(route: "/_specimen", measure: "site")
# Extract color palette for harmony and contrast review
snap(route: "/_specimen", palette: true)
# Assert specific CSS property values — works best for numeric properties
snap(route: "/_specimen", assert: ["css(stencila-paragraph).fontSize>=16px", "css(stencila-heading).lineHeight>=1.2"])
# Assert string CSS properties with the ~= (contains) operator
snap(route: "/_specimen", assert: ["css(stencila-heading).fontFamily~=Source Serif"])
# Full-page screenshot for initial visual overview (opt-in)
snap(route: "/_specimen", screenshot: true, full_page: true)
# Check dark mode rendering with a screenshot
snap(route: "/_specimen", screenshot: true, full_page: true, dark: true)
# Check light mode explicitly
snap(route: "/_specimen", screenshot: true, full_page: true, light: true)
# Responsive checks — use separate calls per device
snap(route: "/_specimen", measure: "theme", device: "mobile")
snap(route: "/_specimen", measure: "theme", device: "desktop")
# Focus on a specific element type
snap(route: "/_specimen", screenshot: true, selector: "stencila-code-block")
snap(route: "/_specimen", screenshot: true, selector: "stencila-table")
# Snap the user's actual document or site pages
# For index-like source files, snap the directory route they render to
snap(route: "/", measure: "theme")
snap(route: "/docs/", screenshot: true, full_page: true, dark: true)
# Print mode emulation (A4 dimensions) — incompatible with dark/light
snap(route: "/_specimen", screenshot: true, print: true)
# Width-only viewport (height falls back to default)
snap(route: "/_specimen", measure: "theme", width: 480)Practical tips
Measurement-first workflow : start with measurement-only runs (the default) to establish baselines, then add screenshots only when visual confirmation is needed. Prefer rendered directory routes over source filenames : when a page comes from index.*, main.*, or README.*, snap the containing directory route because those files behave like that directory's index.html. Token verification is the strongest feature : always use narrow token_prefixvalues like ["text", "heading", "surface"]. Broad prefixes like "color"match 100+ primitive palette tokens and flood context. Use measure: "theme"for holistic layout review and measure: "site"for site chrome (header, nav, footer). Diagnostics about unmatched selectors are informational — they describe what the route contains, not bugs in the theme. The selector_matchedfield in the output tells you whether an element was found, even without a screenshot. Missing selectors in screenshots are handled gracefully — the tool returns a diagnostic instead of hard-erroring. Contrast calculations work on elements with explicit backgrounds. Transparent descendants report "background color is unavailable" — this is expected, not an error. Screenshots work best for : initial full-page overview, print-mode reflow checks, and specific element captures with unique selectors. Avoid full-page screenshots of very tall pages for typography review — use selector-targeted snaps instead (e.g. selector: "stencila-heading"). Prefer unique selectors for element screenshots — when multiple elements match, only the first is captured but measurements cover all matches. Assertions are best for numeric CSS properties (fontSize, lineHeight, width, height, marginTop, etc.). Use the ~=operator for string matching (e.g. fontFamily). Use DOM context for CSS investigation : when a computed value is unexpected, check the dom_contextfor the selector to see the ancestor chain. This helps identify which parent element may be contributing inherited styles or layout constraints, reducing trial-and-error follow-up snaps. Theme changes are cached for ~30 seconds by the server. Batch CSS edits before snapping to see them all reflected. Responsive testing : use separate device: "mobile"and device: "desktop"calls — there is no batch multi-device parameter. Unknown measurevalues produce a validation error listing the valid options — use only the documented presets.