Principle:Nightwatchjs Nightwatch Multi Page Composition
| Knowledge Sources | |
|---|---|
| Domains | Testing, Page_Object_Model, Test_Architecture |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
A test composition pattern that chains multiple page objects together to model user journeys spanning several pages of a web application.
Description
Multi-Page Composition extends the Page Object Pattern to handle user flows that cross page boundaries. A single test may navigate from a search page to a results page, then to a detail page. Each page transition involves instantiating a new page object while the previous one becomes stale. This pattern enables testing complete user journeys (login → dashboard → settings → logout) while maintaining the encapsulation benefits of individual page objects.
Usage
Use multi-page composition when testing user flows that span multiple pages. Each page transition should instantiate the appropriate page object for the destination page.
Theoretical Basis
Multi-page composition follows a state machine model:
- State: Each page object represents the current page state
- Transition: User actions (click, submit) cause page transitions
- New state: A new page object is instantiated for the destination
- Verification: Assertions are made on the new page's elements