externalInteractionObject <NET>
Hierarchy
Implements
Index
Constructors
Methods
Constructors
externalconstructor
Type parameters
- NET
Parameters
externalrootElement: PageElement<NET> | QuestionAdapter<PageElement<NET>>
externaloptionaloptions: InteractionObjectOptions
Returns InteractionObject<NET>
Methods
externalisPresent
Checks whether the interaction object's root element is present in the DOM.
Since
InteractionObjectimplementsOptional, you can assert on presence directly:Ensure.that(view, isPresent())Returns Answerable<boolean>
Base class for interaction objects — the Screenplay Pattern equivalent of Page Objects.
An interaction object models a UI component from the perspective of its consumer: what can a user observe about its state (Questions), and what can they do with it (Tasks)? Implementation details — CSS selectors, DOM structure, responsive breakpoints — are encapsulated inside the interaction object and never leak into tests.
Philosophy
Interaction objects bridge the gap between the Screenplay Pattern and component testing. Where a traditional Page Object exposes imperative methods that perform actions and return values, an interaction object exposes declarative Screenplay building blocks:
outcome(),name(),scenarioCount())open(),find(term),selectFilter(label))Because Questions and Tasks are first-class Screenplay citizens, they compose naturally with
Ensure.that(),Check.whether(),Wait.until(), and other Serenity/JS interactions. Tests read as specifications of user behaviour, not as scripts that manipulate the DOM.Declarative element access
Interaction objects use the Page Element Query Language (PEQL) to locate elements relative to a root element. The
child()andchildren()methods scope all lookups within the interaction object's root, preventing selector collisions between components.Composition
Interaction objects compose into hierarchies that mirror the UI structure:
Child interaction objects are constructed with a scoped root element via
this.child(...):Presence via Optional
Every interaction object implements
Optional, so tests can assert on component presence directly:Creating a custom interaction object
Wiring into a Playwright Test fixture