Skip to main content

Photographer

The Photographer is a StageCrewMember who takes screenshots using the web browser associated with the Actor that is currently in the spotlight.

Registering Photographer programmatically

import { configure, ArtifactArchiver } from '@serenity-js/core'
import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'

configure({
crew: [
ArtifactArchiver.storingArtifactsAt(process.cwd(), 'target/site/serenity'),
Photographer.whoWill(TakePhotosOfFailures),
]
})

Using Photographer with Playwright Test

// playwright.config.ts
import type { PlaywrightTestConfig } from '@serenity-js/playwright-test'

const config: PlaywrightTestConfig = {
reporter: [
[ '@serenity-js/playwright-test', {
crew: [
'@serenity-js/serenity-bdd',
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
]
// other Serenity/JS config
}]
],

use: {
crew: [
[ '@serenity-js/web:Photographer', {
strategy: 'TakePhotosOfFailures',
// strategy: 'TakePhotosOfInteractions',
} ]
],
},
};
export default config;

Learn more

Using Photographer with WebdriverIO

// wdio.conf.ts
import { ArtifactArchiver } from '@serenity-js/core'
import { WebdriverIOConfig } from '@serenity-js/webdriverio'

export const config: WebdriverIOConfig= {

// Tell WebdriverIO to use Serenity/JS framework
framework: '@serenity-js/webdriverio',

serenity: {
// Configure Serenity/JS to use an appropriate test runner adapter
runner: 'cucumber',
// runner: 'mocha',
// runner: 'jasmine',

// register custom Actors class to configure your Serenity/JS actors
actors: new Actors(),

// Register StageCrewMembers we've imported at the top of this file
crew: [
'@serenity-js/serenity-bdd',
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
[ '@serenity-js/web:Photographer', {
strategy: 'TakePhotosOfFailures',
// strategy: 'TakePhotosOfInteractions',
} ]
]
},

// ... rest of the config omitted for brevity
}

Using Photographer with Protractor

// protractor.conf.js
exports.config = {

// Tell Protractor to use the Serenity/JS framework Protractor Adapter
framework: 'custom',
frameworkPath: require.resolve('@serenity-js/protractor/adapter'),

serenity: {
runner: 'jasmine',
// runner: 'cucumber',
// runner: 'mocha',
crew: [
@serenity-js/serenity-bdd',
'@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
'@serenity-js/web:Photographer', {
strategy: 'TakePhotosOfFailures',
// strategy: 'TakePhotosOfInteractions',
]
]
},

// ... rest of the config omitted for brevity
}

Taking photos only upon failures only

import { Photographer, TakePhotosOfFailures } from '@serenity-js/web'

Photographer.whoWill(TakePhotosOfFailures)

Taking photos of all the interactions

import { Photographer, TakePhotosOfInteractions } from '@serenity-js/web'

Photographer.whoWill(TakePhotosOfInteractions)

Taking photos before and after all the interactions

import { Photographer, TakePhotosBeforeAndAfterInteractions } from '@serenity-js/web'

Photographer.whoWill(TakePhotosBeforeAndAfterInteractions)

Learn more

Implements

  • StageCrewMember

Index

Constructors

constructor

Methods

staticwhoWill

staticfromJSON

  • fromJSON(config?: { strategy?: Omit<PhotoTakingStrategy | TakePhotosBeforeAndAfterInteractions | TakePhotosOfFailures | TakePhotosOfInteractions, PhotoTakingStrategy> }): StageCrewMember
  • Instantiates a new Photographer configured to take photos (screenshots) as per the specified PhotoTakingStrategy.


    Parameters

    • optionalconfig: { strategy?: Omit<PhotoTakingStrategy | TakePhotosBeforeAndAfterInteractions | TakePhotosOfFailures | TakePhotosOfInteractions, PhotoTakingStrategy> }

    Returns StageCrewMember

assignedTo

  • assignedTo(stage: Stage): StageCrewMember

notifyOf

  • notifyOf(event: DomainEvent): void
  • Handles DomainEvent objects emitted by the Stage this StageCrewMember is assigned to.


    Parameters

    • event: DomainEvent

    Returns void