Skill v1.0.1
currentAutomated scan100/1007 files
version: "1.0.1" name: pomwright-v2-migration description: > Migrate POMWright page objects to v2 PageObject from either v1 BasePage or the v1.5 bridge (BasePageV1toV2). Use when asked to migrate, convert, or upgrade POMWright page objects to v2, or when working with PageObject. Covers: changing class inheritance and constructor signature, translating addSchema/initLocatorSchemas to defineLocators with v2 DSL, adding pageActionsToPerformAfterNavigation, updating call-site syntax (getLocator, getNestedLocator, getLocatorSchema), updating filter/index/update/mutation patterns, migrating fixtures, navigation, sessionStorage, logging, and adopting the @step decorator.
POMWright v2 Migration (BasePage / BasePageV1toV2 -> PageObject)
Migrate page objects to PageObject from either v1 BasePage or the v1.5 bridge BasePageV1toV2. This is the final migration target; PageObject is the stable v2 API.
Determine source version
Before starting, identify which base class the POC currently extends:
| Current base class | Source version | Key differences from v2 | |
|---|---|---|---|
BasePage | v1 | Constructor requires testInfo, pocName, PlaywrightReportLogger; uses initLocatorSchemas with addSchema; async locator accessors; addFilter + index maps | |
BasePageV1toV2 | v1.5 bridge | Same constructor as v1; may have both initLocatorSchemas and defineLocators; v2 accessors already available but async removed only partially |
If the source is v1 BasePage and has not yet been migrated through the bridge, this skill handles the direct migration. All schema translation and call-site changes still apply.
Workflow
- Inventory the target POC file and its consumers (tests, fixtures, helpers that import it).
- Migrate the class declaration and constructor. See references/class-migration.md.
- Migrate locator definitions into
defineLocators()using the v2add()DSL. See references/locator-registration.md. - Remove `initLocatorSchemas()` once all schemas are moved to
defineLocators(). - Add `pageActionsToPerformAfterNavigation()` (required abstract method). See references/class-migration.md.
- Update call-site syntax in tests, fixtures, and helpers. See references/call-site-migration.md.
- Migrate fixtures and helpers (navigation, sessionStorage, logging, @step). See references/fixture-and-helpers.md.
- Remove v1 imports (
GetByMethod,BasePage,BasePageV1toV2,BasePageOptions,ExtractUrlPathType,ExtractBaseUrlType,ExtractFullUrlType,GetLocatorBase,LocatorSchemaWithoutPath). - Verify by running tests.
Key rules
- v2
PageObjectconstructor takes(page, baseUrl, urlPath, options?)- notestInfo, nopocName, noPlaywrightReportLogger. pocNameis replaced byoptions.label(defaults to class name, so often omittable).testInfoandPlaywrightReportLoggerare no longer injected into PageObject. Use thelogfixture frompomwrightinstead if logging is needed.defineLocators()is required;initLocatorSchemas()does not exist in v2.pageActionsToPerformAfterNavigation()is a required abstract method; returnnullor an array of async callbacks.- v2
getLocator/getNestedLocator/getLocatorSchemaare synchronous (noawait). - v2
getNestedLocatordoes not accept index maps. UsegetLocatorSchema(path).nth(subPath, index).getNestedLocator()instead. filterreplaces v1addFilter.nthreplaces v1 index maps. Both can be chained in any order.- v2
filter.has/filter.hasNotaccept registry path strings in addition to Locator instances. navigationhelper is exposed on PageObject:this.navigation.gotoThisPage(),this.navigation.expectThisPage(), etc.sessionStorageAPI changed: boolean parameters replaced by options objects.@stepdecorator is available for wrapping methods in Playwright test steps.- v1 URL type helpers renamed:
ExtractBaseUrlType->BaseUrlTypeFromOptions,ExtractUrlPathType->UrlPathTypeFromOptions,ExtractFullUrlType->FullUrlTypeFromOptions. The options shape flattened from{ urlOptions: { ... } }to{ baseUrlType, urlPathType }.
References
- Class migration: references/class-migration.md - Inheritance, constructor, generics, abstract methods, base class hierarchy
- Locator registration: references/locator-registration.md - defineLocators, add() DSL mapping, reusable locators, filter/nth at registration, frameLocator changes
- Call-site migration: references/call-site-migration.md - getLocator, getNestedLocator, getLocatorSchema, filter, nth, update, replace, remove, describe
- Fixtures and helpers: references/fixture-and-helpers.md - Fixture setup, navigation helper, sessionStorage, @step decorator, logging