Skip to main content

Overview

The Screenshot node captures images of web pages or specific elements. It supports full-page screenshots, viewport captures, element-specific screenshots, and PDF generation with advanced masking capabilities.

Actions

viewport (Default)

Capture screenshot of the current viewport (visible area).

fullPage

Capture screenshot of the entire page including scrollable areas.

element

Capture screenshot of a specific element.
selector
string
required
Element selector to capture. Supports variable interpolation: ${data.targetElement}
selectorType
string
default:"css"
Type of selector: css, xpath, text, getByRole, etc.
mask
string[]
Array of selectors for elements to mask (blur/hide) in the screenshot. Useful for hiding sensitive data.

pdf

Generate a PDF of the current page.
format
string
default:"A4"
Page format: A4, Letter, Legal, A3, A5, Tabloid
printBackground
boolean
default:"true"
Include background graphics in the PDF.
landscape
boolean
default:"false"
Use landscape orientation.
margin
object
Page margins. Example: {top: '1cm', right: '1cm', bottom: '1cm', left: '1cm'}

Configuration

action
string
required
Action to perform: viewport, fullPage, element, or pdf
path
string
File path to save the screenshot/PDF. If not specified, a default name is generated.Supports variable interpolation: ${data.screenshotName}.png
  • Relative paths are resolved from the project root
  • File extension determines format (.png, .jpg, .pdf)
failSilently
boolean
default:"false"
If true, errors don’t stop workflow execution.

Advanced Features

Waiting

waitForSelector
string
Wait for an element to appear before taking screenshot.
waitForSelectorTimeout
number
default:"30000"
Timeout for waiting for selector.
waitForUrl
string
Wait for URL to match pattern.
waitForCondition
string
Wait for JavaScript condition to be true.
waitAfterOperation
boolean
default:"false"
Execute waits after screenshot instead of before.

Retry Logic

retryEnabled
boolean
default:"false"
Enable automatic retry on failure.
retryCount
number
default:"3"
Number of retry attempts.
retryDelay
number
default:"1000"
Delay between retries in milliseconds.

Outputs

The screenshot path is stored in the context:
  • Variable: screenshotPath
  • Type: string
  • Value: Full path to the saved screenshot file

Examples

Basic Screenshots

{
  "type": "screenshot",
  "data": {
    "action": "viewport",
    "path": "screenshots/page.png"
  }
}

With Masking

{
  "type": "screenshot",
  "data": {
    "action": "fullPage",
    "path": "screenshots/page-masked.png",
    "mask": [
      ".user-email",
      ".credit-card",
      "#personal-info"
    ]
  }
}

PDF Generation

{
  "type": "screenshot",
  "data": {
    "action": "pdf",
    "path": "documents/report.pdf",
    "format": "A4"
  }
}

Dynamic Naming

{
  "type": "screenshot",
  "data": {
    "action": "fullPage",
    "path": "screenshots/page-${data.timestamp}.png"
  }
}

With Wait Conditions

{
  "type": "screenshot",
  "data": {
    "action": "fullPage",
    "path": "screenshots/loaded.png",
    "waitForSelector": ".content-loaded",
    "waitForSelectorTimeout": 10000
  }
}

Advanced Usage

Complete Example
{
  "type": "screenshot",
  "data": {
    "action": "element",
    "selector": ".report-section",
    "selectorType": "css",
    "path": "reports/section-${data.reportId}.png",
    "mask": [".confidential", ".internal-only"],
    "waitForSelector": ".report-ready",
    "waitForSelectorTimeout": 15000,
    "retryEnabled": true,
    "retryCount": 2,
    "retryDelay": 2000
  }
}

File Formats

Image Formats

  • PNG (default): Lossless, supports transparency
  • JPEG: Compressed, smaller file size
Format is determined by file extension:
"path": "screenshot.png"  // PNG format
"path": "screenshot.jpg"  // JPEG format

PDF Options

FormatSize (mm)Use Case
A4210 x 297Standard documents
Letter216 x 279US standard
Legal216 x 356Legal documents
A3297 x 420Large documents
Tabloid279 x 432Presentations

Accessing Screenshot Path

const screenshotPath = context.getData('screenshotPath');
console.log(`Screenshot saved to: ${screenshotPath}`);

// Use in further processing
context.setData('attachmentPath', screenshotPath);

Notes

Full-page screenshots capture content beyond the viewport by scrolling. This works for most pages but may have issues with infinite scroll or lazy-loaded content.
Masked elements are blurred in the screenshot. The mask selectors use the same selectorType as the main selector.
PDF generation is only supported in Chromium-based browsers. It will fail with Firefox or WebKit.

Best Practices

// Use descriptive paths
{
  "path": "screenshots/${data.testName}/${data.stepName}.png"
}

Common Patterns

Screenshot on Error

try {
  // workflow operations
} catch (error) {
  // Take screenshot for debugging
  context.setData('errorScreenshot', true);
}

Before/After Comparison

[
  {
    "type": "screenshot",
    "data": {
      "action": "element",
      "selector": "#form",
      "path": "screenshots/before.png"
    }
  },
  {
    "type": "type",
    "data": {
      "selector": "#input",
      "text": "test data"
    }
  },
  {
    "type": "screenshot",
    "data": {
      "action": "element",
      "selector": "#form",
      "path": "screenshots/after.png"
    }
  }
]

Build docs developers (and LLMs) love