A question is a Screenplay-compatible query that retrieves information about system state through a user interface. An actor answers it using an ability, then uses the result to determine whether the application behaves as expected. section 12.11 section 12.8
Use questions to express observations at the level your test needs:
- Read an element’s text, such as a status level or account balance. section 12.8.1
- Convert a returned value, for example turning a point balance into an integer. section 12.8.1
- Check state directly, such as whether a balance is visible, a field is enabled, or a button is disabled. section 12.8.1
- Wrap repeated or business-specific queries in domain-specific Question classes to improve readability. section 12.8.2
Reading a frequent-flyer balance
A predefined question can locate the point-balance element and convert its text: Text.of("[test-dataid='point-balance']").asInteger(). The actor obtains the actual result by answering it, for example with answeredBy(sally). A domain-specific Account.pointBalance() question can hide that selector and conversion while preserving the business meaning. section 12.8.1 section 12.8.2
Table 12.3 Common Screenplay question classes in Serenity BDD (view table figure)
Common Serenity BDD question classes cover HTML attributes, form values, selected options, text, visibility, and enabled or disabled state. section 12.8.1
In Serenity/JS, web questions such as Text.of, Value.of, and CssClasses.of provide integration-tool-agnostic access to state through PageElement objects. section 15.2.5
