pomwright 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +37 -0
- package/CHANGELOG.md +179 -0
- package/README.md +316 -34
- package/dist/index.d.mts +1052 -30
- package/dist/index.d.ts +1052 -30
- package/dist/index.js +2263 -65
- package/dist/index.mjs +2260 -67
- package/docs/v1-to-v2-migration/bridge-migration-guide.md +159 -0
- package/docs/v1-to-v2-migration/direct-migration-guide.md +238 -0
- package/docs/v1-to-v2-migration/v1-to-v2-comparison.md +547 -0
- package/docs/v2/PageObject.md +293 -0
- package/docs/v2/composing-locator-modules.md +93 -0
- package/docs/v2/locator-registry.md +693 -0
- package/docs/v2/logging.md +168 -0
- package/docs/v2/overview.md +515 -0
- package/docs/v2/session-storage.md +160 -0
- package/index.ts +61 -9
- package/intTestV2/.env +0 -0
- package/intTestV2/fixtures/testApp.fixtures.ts +43 -0
- package/intTestV2/package.json +22 -0
- package/intTestV2/page-object-models/testApp/pages/iframe/iframe.locatorSchema.ts +24 -0
- package/intTestV2/page-object-models/testApp/pages/iframe/iframe.page.ts +17 -0
- package/intTestV2/page-object-models/testApp/pages/testPage.locatorSchema.ts +32 -0
- package/intTestV2/page-object-models/testApp/pages/testPage.page.ts +119 -0
- package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.locatorSchema.ts +29 -0
- package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.page.ts +48 -0
- package/intTestV2/page-object-models/testApp/pages/testPath/testPath.locatorSchema.ts +9 -0
- package/intTestV2/page-object-models/testApp/pages/testPath/testPath.page.ts +23 -0
- package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.locatorSchema.ts +114 -0
- package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.page.ts +23 -0
- package/intTestV2/page-object-models/testApp/testApp.base.ts +20 -0
- package/intTestV2/playwright.config.ts +54 -0
- package/intTestV2/server.js +216 -0
- package/intTestV2/test-data/staticPage/index.html +280 -0
- package/intTestV2/test-data/staticPage/w3images/avatar2.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar3.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar5.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar6.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/forest.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/lights.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/mountains.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/nature.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/snow.jpg +0 -0
- package/intTestV2/tests/locatorRegistry/add/add.describe.spec.ts +54 -0
- package/intTestV2/tests/locatorRegistry/add/add.filter.spec.ts +143 -0
- package/intTestV2/tests/locatorRegistry/add/add.frameLocator.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByAltText.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getById.spec.ts +45 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByLabel.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByPlaceholder.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByRole.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByTestId.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByText.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.getByTitle.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.locator.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/add/add.reuseExisting.spec.ts +66 -0
- package/intTestV2/tests/locatorRegistry/add/add.reuseReusable.spec.ts +311 -0
- package/intTestV2/tests/locatorRegistry/add/add.spec.ts +159 -0
- package/intTestV2/tests/locatorRegistry/filter.cycle.spec.ts +39 -0
- package/intTestV2/tests/locatorRegistry/getLocator/getLocator.spec.ts +253 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.clearSteps.spec.ts +105 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.describe.spec.ts +23 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.filter.spec.ts +368 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getLocator.spec.ts +56 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getNestedLocator.spec.ts +175 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.nth.spec.ts +60 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.remove.spec.ts +32 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.replace.spec.ts +24 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.spec.ts +110 -0
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.update.spec.ts +322 -0
- package/intTestV2/tests/locatorRegistry/getNestedLocator/getNestedLocator.spec.ts +412 -0
- package/intTestV2/tests/locatorRegistry/registry/registry.binding.spec.ts +50 -0
- package/intTestV2/tests/locatorRegistry/validation/validation.locatorSchemaPath.spec.ts +115 -0
- package/intTestV2/tests/locatorRegistry/validation/validation.sub-path.spec.ts +45 -0
- package/intTestV2/tests/step/step.spec.ts +49 -0
- package/intTestV2/tests/testApp/color.spec.ts +15 -0
- package/intTestV2/tests/testApp/iframe.spec.ts +57 -0
- package/intTestV2/tests/testApp/testFilters.spec.ts +24 -0
- package/intTestV2/tests/testApp/testPage.spec.ts +161 -0
- package/intTestV2/tests/testApp/testPath.spec.ts +18 -0
- package/pack-build.sh +11 -0
- package/pack-test-v2.sh +36 -0
- package/package.json +10 -3
- package/playwright.base.ts +42 -0
- package/skills/README.md +56 -0
- package/skills/pomwright-v1-5-bridge-migration/SKILL.md +40 -0
- package/skills/pomwright-v1-5-bridge-migration/references/call-site-migration.md +178 -0
- package/skills/pomwright-v1-5-bridge-migration/references/schema-translation.md +183 -0
- package/skills/pomwright-v2-migration/SKILL.md +63 -0
- package/skills/pomwright-v2-migration/references/call-site-migration.md +265 -0
- package/skills/pomwright-v2-migration/references/class-migration.md +266 -0
- package/skills/pomwright-v2-migration/references/fixture-and-helpers.md +423 -0
- package/skills/pomwright-v2-migration/references/locator-registration.md +344 -0
- package/srcV2/fixture/base.fixtures.ts +23 -0
- package/srcV2/helpers/navigation.ts +153 -0
- package/srcV2/helpers/playwrightReportLogger.ts +196 -0
- package/srcV2/helpers/sessionStorage.ts +251 -0
- package/srcV2/helpers/stepDecorator.ts +106 -0
- package/srcV2/locators/index.ts +15 -0
- package/srcV2/locators/locatorQueryBuilder.ts +427 -0
- package/srcV2/locators/locatorRegistrationBuilder.ts +558 -0
- package/srcV2/locators/locatorRegistry.ts +541 -0
- package/srcV2/locators/locatorUpdateBuilder.ts +602 -0
- package/srcV2/locators/reusableLocatorBuilder.ts +200 -0
- package/srcV2/locators/types.ts +256 -0
- package/srcV2/locators/utils.ts +309 -0
- package/srcV2/locators/v1SchemaTranslator.ts +178 -0
- package/srcV2/pageObject.ts +105 -0
- /package/docs/{BaseApi-explanation.md → v1/BaseApi-explanation.md} +0 -0
- /package/docs/{BasePage-explanation.md → v1/BasePage-explanation.md} +0 -0
- /package/docs/{LocatorSchema-explanation.md → v1/LocatorSchema-explanation.md} +0 -0
- /package/docs/{LocatorSchemaPath-explanation.md → v1/LocatorSchemaPath-explanation.md} +0 -0
- /package/docs/{PlaywrightReportLogger-explanation.md → v1/PlaywrightReportLogger-explanation.md} +0 -0
- /package/docs/{get-locator-methods-explanation.md → v1/get-locator-methods-explanation.md} +0 -0
- /package/docs/{intro-to-using-pomwright.md → v1/intro-to-using-pomwright.md} +0 -0
- /package/docs/{sessionStorage-methods-explanation.md → v1/sessionStorage-methods-explanation.md} +0 -0
- /package/docs/{tips-folder-structure.md → v1/tips-folder-structure.md} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Bridge Migration Guide (BasePage ➜ BasePageV1toV2 ➜ PageObject)
|
|
2
|
+
|
|
3
|
+
This guide is for teams that want a **two-step migration**:
|
|
4
|
+
|
|
5
|
+
1. Move from `BasePage` (v1) to `BasePageV1toV2` (bridge).
|
|
6
|
+
2. Then move from `BasePageV1toV2` to `PageObject` (v2).
|
|
7
|
+
|
|
8
|
+
The bridge preserves v1 locator schema ingestion while exposing v2 registries, allowing gradual conversion.
|
|
9
|
+
|
|
10
|
+
> `BasePageV1toV2` is deprecated and will be removed in 2.0.0. Use it only as a temporary bridge.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Step 1: Migrate `BasePage` to `BasePageV1toV2`
|
|
15
|
+
|
|
16
|
+
### v1 BasePage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
class LoginPage extends BasePage<Paths> {
|
|
20
|
+
constructor(page: Page, testInfo: TestInfo, log: PlaywrightReportLogger) {
|
|
21
|
+
super(page, testInfo, "https://example.com", "/login", "LoginPage", log);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected initLocatorSchemas() {
|
|
25
|
+
this.locators.addSchema({
|
|
26
|
+
locatorSchemaPath: "main.button@login",
|
|
27
|
+
locatorMethod: GetByMethod.role,
|
|
28
|
+
role: "button",
|
|
29
|
+
roleOptions: { name: "Login" },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Bridge: BasePageV1toV2
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
class LoginPage extends BasePageV1toV2<Paths> {
|
|
39
|
+
constructor(page: Page, testInfo: TestInfo, log: PlaywrightReportLogger) {
|
|
40
|
+
super(page, testInfo, "https://example.com", "/login", "LoginPage", log);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected defineLocators(): void {
|
|
44
|
+
// Start migrating here with v2 add(...) calls.
|
|
45
|
+
this.add("main.button@login").getByRole("button", { name: "Login" });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected initLocatorSchemas(): void {
|
|
49
|
+
// Keep v1 schemas temporarily until you migrate them all.
|
|
50
|
+
this.locators.addSchema({
|
|
51
|
+
locatorSchemaPath: "main.form@login",
|
|
52
|
+
locatorMethod: GetByMethod.role,
|
|
53
|
+
role: "form",
|
|
54
|
+
roleOptions: { name: "Login" },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Key points:
|
|
61
|
+
|
|
62
|
+
- `BasePageV1toV2` still requires `testInfo` and `PlaywrightReportLogger`.
|
|
63
|
+
- It exposes **both** v1 schema ingestion (`initLocatorSchemas`) and v2 accessors (`add`, `getLocator`, `getNestedLocator`, `getLocatorSchema`).
|
|
64
|
+
- You can migrate locators incrementally by moving schemas from `initLocatorSchemas` to `defineLocators`.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Step 2: Gradually migrate locators to v2 DSL
|
|
69
|
+
|
|
70
|
+
### Convert one schema at a time
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// v1 schema
|
|
74
|
+
this.locators.addSchema({
|
|
75
|
+
locatorSchemaPath: "main.form@login.input@username",
|
|
76
|
+
locatorMethod: GetByMethod.label,
|
|
77
|
+
label: "Username",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// v2 DSL (preferred)
|
|
81
|
+
this.add("main.form@login.input@username").getByLabel("Username");
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Replace v1 mutations
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// v1
|
|
88
|
+
await page
|
|
89
|
+
.getLocatorSchema("main.form@login.input@username")
|
|
90
|
+
.addFilter("main.form@login", { hasText: "Login" })
|
|
91
|
+
.getNestedLocator();
|
|
92
|
+
|
|
93
|
+
// v2
|
|
94
|
+
page
|
|
95
|
+
.getLocatorSchema("main.form@login.input@username")
|
|
96
|
+
.filter("main.form@login", { hasText: "Login" })
|
|
97
|
+
.getNestedLocator();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Step 3: Remove v1 schema ingestion entirely
|
|
103
|
+
|
|
104
|
+
When all schemas are converted to `defineLocators`, delete `initLocatorSchemas` and switch to `PageObject`.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
class LoginPage extends PageObject<Paths> {
|
|
108
|
+
constructor(page: Page) {
|
|
109
|
+
super(page, "https://example.com", "/login", { label: "LoginPage" });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
protected defineLocators(): void {
|
|
113
|
+
this.add("main.form@login.input@username").getByLabel("Username");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
protected pageActionsToPerformAfterNavigation() {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Step 4: Update API usage
|
|
125
|
+
|
|
126
|
+
After switching to `PageObject`, update the remaining call sites:
|
|
127
|
+
|
|
128
|
+
- `getLocator` / `getNestedLocator` are synchronous and the latter no longer accept index maps.
|
|
129
|
+
- `SessionStorage` signatures changed (`set(states, { reload, waitForContext })`).
|
|
130
|
+
- PageObject does not implement `testInfo` and `PlaywrightReportLogger` while v1 `BasePage` does, if you want them in your POCs you'll need to add them.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Bridge checklist
|
|
135
|
+
|
|
136
|
+
- [ ] Replace extend `BasePage` with extend `BasePageV1toV2`.
|
|
137
|
+
- [ ] Add `defineLocators()` and start migrating schemas.
|
|
138
|
+
- [ ] Migrate all locator schemas to `defineLocators`.
|
|
139
|
+
- [ ] Update FrameLocators (see [v1-to-v2-comparison.md](docs/v1-to-v2-migration/v1-to-v2-comparison.md))
|
|
140
|
+
- [ ] Update getById regex patterns (see [v1-to-v2-comparison.md](docs/v1-to-v2-migration/v1-to-v2-comparison.md))
|
|
141
|
+
- [ ] Replace v1 `getLocatorSchema(path).addFilter(...)` with v2 `getLocatorSchema(path).filter(...)`.
|
|
142
|
+
- [ ] Replace v1 getNestedLocator index maps with v2 `getLocatorSchema(path).nth(...)`.
|
|
143
|
+
- [ ] Update v1 `getLocatorSchema(path).update(...)` with v2 `getLocatorSchema(path)`... `.update(...)` / `.nth(...)` / `.filter(...)` etc.
|
|
144
|
+
- [ ] Replace extend `BasePageV1toV2` with extend `PageObject`. See [direct-migration-guide.md](docs/v1-to-v2-migration/direct-migration-guide.md)
|
|
145
|
+
- [ ] Update logging and session storage usage.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## When to avoid the bridge
|
|
150
|
+
|
|
151
|
+
Skip `BasePageV1toV2` if:
|
|
152
|
+
|
|
153
|
+
- You can migrate all locators and method calls quickly.
|
|
154
|
+
- You want to adopt v2 URL typing and navigation immediately.
|
|
155
|
+
- You do not need the old `GetLocatorBase` or schema objects.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
For a full feature comparison and method mapping, see [v1-to-v2-comparison.md](docs/v1-to-v2-migration/v1-to-v2-comparison.md).
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Direct v1 ➜ v2 Migration Guide
|
|
2
|
+
|
|
3
|
+
This guide shows how to migrate directly from `BasePage` (v1) to `PageObject` (v2). It focuses on the structural changes, locator conversion, and API differences you must address.
|
|
4
|
+
|
|
5
|
+
> v1 is deprecated and will be removed in 2.0.0. v1.5.0 is the final v1 release.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1) Inventory your v1 usage
|
|
10
|
+
|
|
11
|
+
Before changing code, list where the following appear:
|
|
12
|
+
|
|
13
|
+
- `BasePage` subclasses.
|
|
14
|
+
- `initLocatorSchemas` definitions.
|
|
15
|
+
- `LocatorSchema` objects and `GetByMethod` usage.
|
|
16
|
+
- `getLocatorSchema(...).update(...)` and `addFilter(...)` chains.
|
|
17
|
+
- `getLocator` / `getNestedLocator` wrappers.
|
|
18
|
+
- `SessionStorage` usage (old signatures).
|
|
19
|
+
- `PlaywrightReportLogger` usage in constructors.
|
|
20
|
+
- Any `data-cy` selectors or custom selector engines.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2) Convert `BasePage` to `PageObject`
|
|
25
|
+
|
|
26
|
+
### v1
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
class LoginPage extends BasePage<Paths> {
|
|
30
|
+
constructor(page: Page, testInfo: TestInfo, log: PlaywrightReportLogger) {
|
|
31
|
+
super(page, testInfo, "https://example.com", "/login", "LoginPage", log);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected initLocatorSchemas() {
|
|
35
|
+
this.locators.addSchema({
|
|
36
|
+
locatorSchemaPath: "main.button@login",
|
|
37
|
+
locatorMethod: GetByMethod.role,
|
|
38
|
+
role: "button",
|
|
39
|
+
roleOptions: { name: "Login" },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### v2
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
class LoginPage extends PageObject<Paths> {
|
|
49
|
+
constructor(page: Page) {
|
|
50
|
+
super(page, "https://example.com", "/login", { label: "LoginPage" });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected defineLocators(): void {
|
|
54
|
+
this.add("main.button@login").getByRole("button", { name: "Login" });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected pageActionsToPerformAfterNavigation() {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Key changes:
|
|
64
|
+
|
|
65
|
+
- Remove `testInfo`, `PlaywrightReportLogger`, and `pocName` constructor args.
|
|
66
|
+
- Use `defineLocators()` instead of `initLocatorSchemas()`.
|
|
67
|
+
- Provide `pageActionsToPerformAfterNavigation()`.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3) Translate v1 locator schemas to v2 `add(...)`
|
|
72
|
+
|
|
73
|
+
### v1 locator schema
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
this.locators.addSchema({
|
|
77
|
+
locatorSchemaPath: "main.form@login.input@username",
|
|
78
|
+
locatorMethod: GetByMethod.label,
|
|
79
|
+
label: "Username",
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### v2 registry DSL
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
this.add("main.form@login.input@username").getByLabel("Username");
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Mapping guide:
|
|
90
|
+
|
|
91
|
+
| v1 `locatorMethod` | v2 method |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| `role` | `getByRole(...)` |
|
|
94
|
+
| `text` | `getByText(...)` |
|
|
95
|
+
| `label` | `getByLabel(...)` |
|
|
96
|
+
| `placeholder` | `getByPlaceholder(...)` |
|
|
97
|
+
| `altText` | `getByAltText(...)` |
|
|
98
|
+
| `title` | `getByTitle(...)` |
|
|
99
|
+
| `locator` | `locator(...)` |
|
|
100
|
+
| `frameLocator` | `frameLocator(...)` |
|
|
101
|
+
| `testId` | `getByTestId(...)` |
|
|
102
|
+
| `id` (custom) | `getById(...)` (custom) |
|
|
103
|
+
| `dataCy` (custom) | `locator('[data-cy="..."]')` |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 4) Replace `getLocator` / `getNestedLocator`
|
|
108
|
+
|
|
109
|
+
In v1 these were async wrappers and accepted index maps. In v2 they are synchronous and do not accept index maps.
|
|
110
|
+
|
|
111
|
+
### v1
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const submit = await poc.getNestedLocator("main.form.button@submit", {
|
|
115
|
+
"main.form": 0,
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### v2
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const submit = poc
|
|
123
|
+
.getLocatorSchema("main.form.button@submit")
|
|
124
|
+
.nth("main.form", 0)
|
|
125
|
+
.getNestedLocator();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 5) Replace v1 `getLocatorSchema().update()` and `addFilter()`
|
|
131
|
+
|
|
132
|
+
### v1
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
const submit = await poc
|
|
136
|
+
.getLocatorSchema("main.form.button@submit")
|
|
137
|
+
.update("main.form.button@submit", { roleOptions: { name: "Sign in" } })
|
|
138
|
+
.addFilter("main.form.button@submit", { hasText: /Sign in/i })
|
|
139
|
+
.getNestedLocator();
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### v2
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
const submit = poc
|
|
146
|
+
.getLocatorSchema("main.form.button@submit")
|
|
147
|
+
.update("main.form.button@submit")
|
|
148
|
+
.getByRole({ name: "Sign in" })
|
|
149
|
+
.filter("main.form.button@submit", { hasText: /Sign in/i })
|
|
150
|
+
.getNestedLocator();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 6) Update SessionStorage usage
|
|
156
|
+
|
|
157
|
+
### v1
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
await poc.sessionStorage.set({ token: "abc" }, true);
|
|
161
|
+
const data = await poc.sessionStorage.get(["token"]);
|
|
162
|
+
await poc.sessionStorage.clear();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### v2
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
await poc.sessionStorage.set({ token: "abc" }, { reload: true });
|
|
169
|
+
const data = await poc.sessionStorage.get(["token"], { waitForContext: true });
|
|
170
|
+
await poc.sessionStorage.clear({ waitForContext: true });
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 7) Replace BasePage logging
|
|
176
|
+
|
|
177
|
+
In v1, `BasePage` receives `PlaywrightReportLogger` and keeps it internally. In v2, logging is provided by the `test` fixture.
|
|
178
|
+
|
|
179
|
+
### v2 fixture
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { test } from "pomwright";
|
|
183
|
+
|
|
184
|
+
test("login flow", async ({ page, log }) => {
|
|
185
|
+
log.info("starting login");
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
If you want logging inside POMs, pass a child logger explicitly.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 8) Update navigation flows
|
|
194
|
+
|
|
195
|
+
v2 adds a navigation helper to `PageObject` and expects a `pageActionsToPerformAfterNavigation()` method.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
protected pageActionsToPerformAfterNavigation() {
|
|
199
|
+
return [
|
|
200
|
+
async () => {
|
|
201
|
+
await this.getNestedLocator("main.form@login").waitFor({ state: "visible" });
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
await loginPage.navigation.gotoThisPage();
|
|
207
|
+
await loginPage.navigation.expectAnotherPage();
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 9) Remove v1-only APIs
|
|
213
|
+
|
|
214
|
+
- `BaseApi` is deprecated and not part of v2. Use your own API base class.
|
|
215
|
+
- `GetBy` and `LocatorSchema` objects are replaced by the registry DSL.
|
|
216
|
+
- `data-cy` selector engine is removed; use `locator('[data-cy="..."]')` or register your own selector engine in Playwright.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 10) Validate after migration
|
|
221
|
+
|
|
222
|
+
- Run tests.
|
|
223
|
+
- Check all POMs compile with strict types.
|
|
224
|
+
- Confirm registry paths match the new dot-delimited rules (no whitespace).
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Summary checklist
|
|
229
|
+
|
|
230
|
+
- [ ] Replace `BasePage` with `PageObject`.
|
|
231
|
+
- [ ] Move `initLocatorSchemas` → `defineLocators`.
|
|
232
|
+
- [ ] Convert `LocatorSchema` objects to `add(...).getBy...` calls.
|
|
233
|
+
- [ ] Replace `addFilter` and index maps with `filter` + `nth`.
|
|
234
|
+
- [ ] Update `SessionStorage` signatures.
|
|
235
|
+
- [ ] Remove `data-cy` and custom selector engine assumptions.
|
|
236
|
+
- [ ] Adopt the v2 `test` fixture for logging or implement it directly, see docs/v2/logging.md.
|
|
237
|
+
|
|
238
|
+
For the bridge option, see `bridge-migration-guide.md`.
|