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
