Lupa API Reference / commands / Screenshot
Class: Screenshot
Defined in: src/commands/screenshot.ts:48
Handles capturing screenshots of the page or specific elements.
Use
when
- Capturing visual state of the application for visual regression testing or automated UI verification.
Dont
use when
- Running tests where visual assets are not needed, as capturing screenshots adds execution overhead.
Constructors
Constructor
new Screenshot():
Screenshot
Returns
Screenshot
Methods
take()
take(
options):Promise<void>
Defined in: src/commands/screenshot.ts:62
Takes a screenshot of the entire page.
Parameters
options
Options for the screenshot, requires path.
Returns
Promise<void>
A promise that resolves when the screenshot is saved.
Example
typescript
import { screenshot } from '@pawel-up/lupa/commands'
await screenshot.take({ path: 'screenshots/home-page.png' })takeOf()
takeOf(
query,options):Promise<void>
Defined in: src/commands/screenshot.ts:83
Takes a screenshot of a specific element using a locator query.
Parameters
query
The query matching the target element.
options
Options for the screenshot, requires path.
Returns
Promise<void>
A promise that resolves when the screenshot is saved.
Example
typescript
import { screenshot } from '@pawel-up/lupa/commands'
await screenshot.takeOf({ css: '#my-chart' }, { path: 'screenshots/chart.png' })