A QuestionAdapter is a proxy that presents static, dynamic, or asynchronously resolved data through one Screenplay API. It lets tasks accept values from an actor’s notepad without knowing whether those values are immediately available or lazy-loaded. section 15.1.6
Use a QuestionAdapter when a task must support both fixed inputs and values resolved during execution:
- Replace a task parameter such as TravelerDetails with QuestionAdapter<TravelerDetails> when details come from the notepad. section 15.1.6
- Create partially overridden data with Question.fromObject, merging static fields with dynamic or asynchronous values. section 15.1.6
- Reference proxied fields and methods like ordinary object members; nested members are wrapped recursively. section 15.1.6
- Use the same adapter idea in Lean Page Objects to turn low-level widget data, such as CSS classes, into meaningful states. section 15.2.3
Reusable sign-up task
A sign-up task can accept QuestionAdapter<TravelerDetails>, allowing one step to use notes<TravelerNotes>().get('travelerDetails') while another merges those defaults with an email override through Question.fromObject. The registration-form task can then read travelerDetails.email, travelerDetails.password, and other fields without handling resolution explicitly. section 15.1.6
Listing 15.6 Negative scenario: Signing up using duplicate email address
Feature: Sign up
Rule: Duplicate usernames are not allowed
Scenario: Sign up using duplicate email address
Mike Smith is an existing Frequent Flyer member.
His wife Jenny Smith does not have a Frequent Flyer account.
Given Mike has signed up using the following details:
| email | smiths@example.org |
When Jenny tries to sign up using:
| email | smiths@example.org |
Then she should be advised of an error: "Email exists"
Explore a duplicate-email scenario that demonstrates how reusable sign-up steps support negative test variations. section 15.1.6
