Generating Page Objects | Bondar Academy
Course: Claude Code for Playwright
Module: Playwright Workflows with Claude Code
Instructor: Artem Bondar
Lesson Summary
This video lesson discusses the process of creating page objects using Cloud Code . The speaker explains how to refactor existing code into a Page Object Model (POM) and introduces a skill designed for this purpose. Key Steps in Refactoring to POM Define Patterns: Establish the patterns you want to follow for the page objects. User Input: Ask the user whether to refactor all tests or a specific test by providing the test name. Inventory Existing POM: Analyze the current structure, including pages, fixtures, and helpers. Analyze Tests: Review tests end-to-end, mapping test steps to corresponding page components. POM Rules Locator Management: Keep locators within page object methods rather than in constructors. Method Structure: Ensure methods have meaningful flows and avoid overly simplistic methods. Page Boundaries: Each page method should handle operations specific to that page. Validation: Implement validation at the start and end of methods to prevent flakiness. Assertion Methods: Include separate assertion methods within page objects. Reuse Methods: Check for existing methods before creating new ones. Refactoring Process The speaker demonstrates the refactoring process using the skill pw refactor into POM . The Cloud Code inspects the project structure, maps test steps, and refactors the spec files into POM. After running the tests, all tests pass successfully, showcasing the efficiency of the process. In conclusion, the speaker emphasizes the speed and convenience of using coding agents for refactoring, suggesting that manual methods may be less efficient.