Skip to main content

Set

The Set class is an action class in the Screenplay pattern designed for use with the @testla/screenplay library. This class allows actors to set either Session Storage Items or Local Storage Items on the browser using the BrowseTheWeb ability provided by Testla.

Extends

This class extends the abstract Action class from Core.

Methods

performAs

public performAs(actor: Actor): Promise<any>;
  • Description: Sets the specified storage item in either Session Storage or Local Storage.
  • Parameters:
    • actor - The actor performing this action.
  • Returns: Promise<any> - Returns the value of the pageFunction invocation.

sessionStorageItem

public static sessionStorageItem(key: string, value: any): Set;
  • Description: Creates a new instance of the Set class specifically for setting a session storage item identified by the given key and value.
  • Parameters:
    • key - The key that specifies the item.
    • value - The value of the item.
  • Returns: Set - Returns a new Set instance for session storage.

localStorageItem

public static localStorageItem(key: string, value: any): Set;
  • Description: Creates a new instance of the Set class specifically for setting a local storage item identified by the given key and value.
  • Parameters:
    • key - The key that specifies the item.
    • value - The value of the item.
  • Returns: Set - Returns a new Set instance for local storage.

Methods inherited from Core Action

orSkipOnFail

Introduced in core: 0.5.0

public get orSkipOnFail(): Action;
  • Description: Allows to skip an action on fail.
  • Returns: Action - Returns the current action.

Usage:

// Would skip the step on error without breaking the execution
await actor.attemptsTo(
Do.something().orSkipOnFail,
);

withAbilityAlias

Introduced in core: 0.3.0

public withAbilityAlias(alias: string): Action;
  • Description: Defines the ability alias to be used during execution.
  • Parameters:
    • alias - The alias.
  • Returns: Action - Returns the current action.

Usage:

await actor.attemptsTo(
Do.something().withAbilityAlias('myAlias'),
);