Page Objects Manager | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Page Objects
Instructor: Artem Bondar
Lesson Summary
In this lesson, we introduce the concept of the Page Object Manager to improve our testing framework. This approach simplifies the management of page objects by creating a single orchestrator that handles all instances of the page objects, rather than initializing them in each test. Key Improvements Previously, each test required importing and initializing multiple page objects, which was cumbersome, especially with many tests and spec files. With the Page Object Manager, we only need to import a single manager class, streamlining the process. Implementation Steps Create a new file named PageManager.ts under the page objects directory. Import necessary page objects into this manager. Define a new class PageManager with fields for each page object: NavigateTo for NavigationPage FormLayoutsPage for FormLayoutsPage DatePickerPage for DatePickerPage Implement a constructor that initializes these page objects using a page fixture . Usage in Tests In the test files, import the PageManager and create an instance: const pomNewPageManager = new PageManager(page); Use the manager to access page methods, simplifying the test code and reducing the number of imports needed. Concerns about performance due to initializing all page objects are addressed, as these objects are lightweight and do not significantly impact performance. In summary, the Page Object Manager enhances organization and efficiency in managing page objects across tests.