liveBook · Manning

attemptsTo

As explained in BDD in Action, Second Edition

attemptsTo is a Screenplay API method that directs an actor to perform a sequence of interactions.

attemptsTo is a Screenplay API method that directs an actor to perform one or more interactions or activities. Passing a sequence in one call keeps the action flow readable instead of repeating separate method calls. section 12.5.1

Logging in with one action sequence

Tracy can open the application, select Login, enter an email and password, and click the login button through one attemptsTo call. Common interactions include Open, Click, Enter, Clear, Scroll, and dropdown-selection actions. section 12.5.1

In Serenity/JS, actor.attemptsTo(...) is asynchronous and returns a Promise. Simple Cucumber.js step definitions return that Promise; more complex definitions use async and await, including steps involving multiple actors. section 14.3

Listing 14.7 Example step definition implementation with Cucumber.js
// "When Tracy signs up using valid traveler details"
When('{actor} signs up using valid traveler details', (actor: Actor) =>     
  actor.attemptsTo(                                                         
    SignUp.using(                                                           
      notes<TravelerNotes>().get('travelerDetails')                         
    ),
    VerifySubmission.succeededWith('registered successfully')
  ));

A Cucumber.js step definition maps a business-readable signup step to a sequence of Screenplay tasks and verification activities. section 14.3

How BDD in Action, Second Edition covers it

How deep it goes
Explains grouped interactions and asynchronous Promise handling, but defers the internal implementation of individual interactions and tasks.
Examples
Demonstrates Frequent Flyers login actions and signup steps that combine domain tasks with registration verification.
What it assumes
Assumes familiarity with actors and Screenplay interactions, while demonstrating grouped activities and asynchronous step-definition patterns.
What you can do after
Implement readable actor workflows and correctly synchronize Serenity/JS step definitions with a test runner.
How it connects
Connects actors with Screenplay Pattern interactions, tasks, Cucumber.js step definitions, Promises, and async/await.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.