w3c-webdriver
  • Introduction
  • Capabilities
  • Sessions
  • Timeouts
  • Navigation
  • Contexts
  • Elements
  • Document
  • Cookies
  • Actions
  • User prompts
  • Screen capture
  • Examples
    • Cucumber Functional Tests
  • Resources
    • GitHub
    • WebDriver spec
    • MDN docs
Powered by GitBook
On this page
  • session.takeScreenshot()
  • element.takeScreenshot()

Was this helpful?

Screen capture

PreviousUser prompts

Last updated 3 years ago

Was this helpful?

session.takeScreenshot()

Takes a screenshot of the top-level browsing context’s viewport.

RETURNS

Promise<Buffer>

EXAMPLES

const screenshot = await session.takeScreenshot();
// screenshot = Buffer containing PNG

SEE ALSO

element.takeScreenshot()

Takes a screenshot of the visible region encompassed by the bounding rectangle of an element

RETURNS

Promise<Buffer>

EXAMPLES

const screenshot = await session.takeScreenshot();
// screenshot = Buffer containing PNG

SEE ALSO

WebDriver spec
WebDriver spec