import {TakeNotes} from '@serenity-js/core/lib/screenplay/abilities'
public class | source

Static Method Summary

Static Public Methods
public static

as(actor: UsesAbilities & AnswersQuestions): TakeNotes

Retrieves the Ability to TakeNotes for a given Actor to be used in custom Interactions.

public static

Instantiates an ability to TakeNotes that uses a notepad that can be shared amongst Actors.

public static

Instantiates an ability to TakeNotes that uses an empty notepad.

Constructor Summary

Public Constructor
public

constructor(notepad: Map<string, any>)

Instantiates the Ability to TakeNotes

Method Summary

Public Methods
public

answerTo(subject: Question<Promise<Answer>> | Question<Answer> | string): Promise<Answer>

Recalls the answer to a given Question

public

discard(): Promise<void> | void

Enables the Actor to clear the notepad when the SceneFinishes.

public

record(subject: Question<Promise<Answer>> | Question<Answer> | string, value: Promise<Answer> | Answer): void

Records the answer to a given Question

Static Public Methods

public static as(actor: UsesAbilities & AnswersQuestions): TakeNotes source

Retrieves the Ability to TakeNotes for a given Actor to be used in custom Interactions.

Params:

NameTypeAttributeDescription
actor UsesAbilities & AnswersQuestions

Returns:

TakeNotes

public static usingASharedNotepad(): TakeNotes source

Instantiates an ability to TakeNotes that uses a notepad that can be shared amongst Actors.

This method should be used when you need the Actors to TakeNotes of answers to some Questions, share those notes amongst themselves, and retrieve such shared Notes later on in the same scenario.

Returns:

TakeNotes

Examples:

 import { actorCalled, Note, TakeNote, TakeNotes } from '@serenity-js/core'
 import { ManageALocalServer, StartLocalTestServer, StopLocalTestServer } from '@serenity-js/local-server'
 import { BrowseTheWeb } from '@serenity-js/protractor'

 const server = http.createServer(function (request, response) {
     response.setHeader('Connection', 'close');
     response.end('Hello!');
 });

 const Adam = actorCalled('Adam').whoCan(
     ManageALocalServer.using(server),
     TakeNotes.usingASharedNotepad(),
 );

 const Becky = actorCalled('Becky').whoCan(
     TakeNotes.usingASharedNotepad(),
     BrowseTheWeb.using(protractor.browser),
 );

 Adam.attemptsTo(
     StartLocalTestServer.onRandomPort(),
     TakeNote.of(LocalServer.url()),
 );

 Becky.attemptsTo(
     Navigate.to(Note.of(LocalServer.url())),
     // perform some UI interactions
 );

public static usingAnEmptyNotepad(): TakeNotes source

Instantiates an ability to TakeNotes that uses an empty notepad.

This method should be used when you need the Actor to TakeNote of an answer to some Question and retrieve such Note later on in the same scenario, but you don't need the Actors to share their notes.

Returns:

TakeNotes

Examples:

 import { actorCalled, Log, Note, TakeNote, TakeNotes } from '@serenity-js/core'
 import { BrowseTheWeb, Target, Text } from '@serenity-js/protractor'
 import { by, protractor } from 'protractor';

 const actor = actorCalled('Apisitt').whoCan(
     TakeNotes.usingAnEmptyNotepad(),
     CallAnApi.at('https://api.example.org'),
 );

 actor.attemptsTo(
     Send.a(GetRequest.to('/customers')),
     TakeNote.of(LastResponse.status()),     // remember the LastResponse.status()
     // ... perform some other activities
     Log.the(Note.of(LastResponse.body())),  // log it later, or pass to any other interaction
 );
 import { actorCalled, Note, TakeNote, TakeNotes } from '@serenity-js/core'
 import { BrowseTheWeb, Target, Text } from '@serenity-js/protractor'
 import { by, protractor } from 'protractor';

 class Vouchers {
     static code             = Target.the('voucher code').located(by.id('voucher'));
     static appliedVoucher   = Target.the('voucher code').located(by.id('applied-voucher'));
 }

 const actor = actorCalled('Noah').whoCan(
     TakeNotes.usingAnEmptyNotepad(),
     BrowseTheWeb.using(protractor.browser),
 );

 actor.attemptsTo(
     TakeNote.of(Text.of(Vouchers.code)),
     // ... add the product to a basket, go to checkout, etc.
     Ensure.that(Text.of(Vouchers.appliedVoucher), equals(Note.of(Text.of(Vouchers.code)))),
 );

Public Constructors

public constructor(notepad: Map<string, any>) source

Instantiates the Ability to TakeNotes

Params:

NameTypeAttributeDescription
notepad Map<string, any>

Public Methods

public answerTo(subject: Question<Promise<Answer>> | Question<Answer> | string): Promise<Answer> source

Recalls the answer to a given Question

Params:

NameTypeAttributeDescription
subject Question<Promise<Answer>> | Question<Answer> | string

Question or name the Answer was recorded as

Returns:

Promise<Answer>

public discard(): Promise<void> | void source

Enables the Actor to clear the notepad when the SceneFinishes.

Returns:

Promise<void> | void

public record(subject: Question<Promise<Answer>> | Question<Answer> | string, value: Promise<Answer> | Answer): void source

Records the answer to a given Question

Params:

NameTypeAttributeDescription
subject Question<Promise<Answer>> | Question<Answer> | string

Question or name to record the Answer as

value Promise<Answer> | Answer

The Answer to record

Returns:

void