1.7 KiB
1.7 KiB
Create Page Object Command
Description
Create a Page Object Model (POM) for a specific page or component. Generates a TypeScript class with locators and methods following the Page Object pattern with data-testid locators.
Usage
/create-page-object [page-name]
Parameters
page-name- Name of the page or component (required)
Examples
/create-page-object LoginPage
/create-page-object ProductDetailsPage
/create-page-object CheckoutForm
Instructions for Claude
When this command is invoked:
-
Invoke the page-object-builder skill to handle the Page Object creation
-
Gather information:
- Page name and URL
- Key elements on the page
- Common user actions
- data-testid values for elements
-
Generate Page Object class:
- TypeScript class with proper types
- Readonly locators using data-testid
- Constructor accepting Page object
- goto() method for navigation
- Action methods (async)
- Getter methods for assertions
-
Provide usage example:
- Show how to use the Page Object in tests
- Demonstrate common actions
- Show assertion patterns
-
List required data-testid values:
- Document all testid values needed in the UI
- Provide semantic naming suggestions
Error Handling
- If page name is missing, prompt for it
- If insufficient information, ask for page details
- Suggest data-testid names if not provided
- Warn if Page Object seems too large (consider splitting)
Notes
- All locators must use data-testid
- Page Objects should not contain assertions
- Use getters for elements that need assertions
- Keep Page Objects focused on a single page/component