Skip to content
All guides

How To Automatically Screenshot Modals, Dropdowns and Tabs

Two ways to capture an open modal, an expanded dropdown or a selected tab for your docs, and keep them current: a Playwright script you maintain, or views that follow plain-language steps.

A screenshot of a page as it loads shows none of these states. Each one needs a browser that clicks first. With Playwright you script the clicks; with ScreenshotAgent you describe them, and both can run again after every release.

Step-by-step implementation

  1. 1

    With Playwright, open the page and click to reach the state, for example await page.getByRole('button', { name: 'Settings' }).click(), then await page.getByRole('tab', { name: 'Billing' }).click().

    Step 1
  2. 2

    Wait for the state to appear, for example await page.getByRole('dialog').waitFor(). waitFor() returns as soon as the dialog is visible, while a fade-in can still be running, so turn animations off for the screenshot.

    Step 2
  3. 3

    Take the screenshot: await page.getByRole('dialog').screenshot({ path: 'billing-tab.png', animations: 'disabled' }) for just the modal, or page.screenshot({ fullPage: true, animations: 'disabled' }) for the whole page. Dropdown menus are often rendered outside the button's container, so take the page or a region rather than the button's parent.

    Step 3
  4. 4

    Run the script in CI after each release and commit or upload the new images. When a button is renamed or moved, update the selectors in the script.

    Step 4
  5. 5

    Without a script, capture the page in ScreenshotAgent, then add a view in its view tree and describe the steps in plain words: "Click the Settings button in the top right, then the Billing tab." Or use Point & Click to click on the screenshot where the agent should click.

    Step 5
  6. 6

    Let Auto-Discover find the states for you: it explores the page, finds elements that open modals, menus and tabs, and creates a view for each.

    Step 6
  7. 7

    Set a recapture schedule, or trigger recaptures from CI with the Recapture API. Each public view has its own permanent image URL, so the modal or tab in your help article updates where your docs load images from that URL (with Needs approval on, after someone approves it).

    Step 7

FAQ

Which should I use?
If engineers own the docs and already run Playwright, a script costs nothing extra and lives in your repo. If writers or support keep the screenshots current, or the UI changes often, views avoid maintaining selectors: views you describe in plain words are followed by the AI agent on every recapture, so a renamed or moved button is still found by its description.
What about pages behind a login?
In Playwright, sign in first and save the session with storageState. In ScreenshotAgent, save the login on the project and views use it.
Can views nest?
Yes: a modal on a page, then a tab inside that modal, each with its own screenshot and version history.

Run this guide in ScreenshotAgent

Start with one project and apply this workflow to keep screenshots accurate with less effort.

Start free trial14-day trial · 5 captures free · No card required