pomwright 1.5.0 → 2.0.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +5 -5
  3. package/dist/index.d.mts +91 -989
  4. package/dist/index.d.ts +91 -989
  5. package/dist/index.js +627 -1887
  6. package/dist/index.mjs +633 -1888
  7. package/package.json +9 -11
  8. package/AGENTS.md +0 -37
  9. package/docs/v1/BaseApi-explanation.md +0 -63
  10. package/docs/v1/BasePage-explanation.md +0 -96
  11. package/docs/v1/LocatorSchema-explanation.md +0 -271
  12. package/docs/v1/LocatorSchemaPath-explanation.md +0 -165
  13. package/docs/v1/PlaywrightReportLogger-explanation.md +0 -56
  14. package/docs/v1/get-locator-methods-explanation.md +0 -250
  15. package/docs/v1/intro-to-using-pomwright.md +0 -899
  16. package/docs/v1/sessionStorage-methods-explanation.md +0 -38
  17. package/docs/v1/tips-folder-structure.md +0 -38
  18. package/docs/v1-to-v2-migration/bridge-migration-guide.md +0 -159
  19. package/docs/v1-to-v2-migration/direct-migration-guide.md +0 -238
  20. package/docs/v1-to-v2-migration/v1-to-v2-comparison.md +0 -547
  21. package/docs/v2/PageObject.md +0 -293
  22. package/docs/v2/composing-locator-modules.md +0 -93
  23. package/docs/v2/locator-registry.md +0 -693
  24. package/docs/v2/logging.md +0 -168
  25. package/docs/v2/overview.md +0 -515
  26. package/docs/v2/session-storage.md +0 -160
  27. package/index.ts +0 -75
  28. package/intTestV2/.env +0 -0
  29. package/intTestV2/fixtures/testApp.fixtures.ts +0 -43
  30. package/intTestV2/package.json +0 -22
  31. package/intTestV2/page-object-models/testApp/pages/iframe/iframe.locatorSchema.ts +0 -24
  32. package/intTestV2/page-object-models/testApp/pages/iframe/iframe.page.ts +0 -17
  33. package/intTestV2/page-object-models/testApp/pages/testPage.locatorSchema.ts +0 -32
  34. package/intTestV2/page-object-models/testApp/pages/testPage.page.ts +0 -119
  35. package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.locatorSchema.ts +0 -29
  36. package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.page.ts +0 -48
  37. package/intTestV2/page-object-models/testApp/pages/testPath/testPath.locatorSchema.ts +0 -9
  38. package/intTestV2/page-object-models/testApp/pages/testPath/testPath.page.ts +0 -23
  39. package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.locatorSchema.ts +0 -114
  40. package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.page.ts +0 -23
  41. package/intTestV2/page-object-models/testApp/testApp.base.ts +0 -20
  42. package/intTestV2/playwright.config.ts +0 -54
  43. package/intTestV2/server.js +0 -216
  44. package/intTestV2/test-data/staticPage/index.html +0 -280
  45. package/intTestV2/test-data/staticPage/w3images/avatar2.png +0 -0
  46. package/intTestV2/test-data/staticPage/w3images/avatar3.png +0 -0
  47. package/intTestV2/test-data/staticPage/w3images/avatar5.png +0 -0
  48. package/intTestV2/test-data/staticPage/w3images/avatar6.png +0 -0
  49. package/intTestV2/test-data/staticPage/w3images/forest.jpg +0 -0
  50. package/intTestV2/test-data/staticPage/w3images/lights.jpg +0 -0
  51. package/intTestV2/test-data/staticPage/w3images/mountains.jpg +0 -0
  52. package/intTestV2/test-data/staticPage/w3images/nature.jpg +0 -0
  53. package/intTestV2/test-data/staticPage/w3images/snow.jpg +0 -0
  54. package/intTestV2/tests/locatorRegistry/add/add.describe.spec.ts +0 -54
  55. package/intTestV2/tests/locatorRegistry/add/add.filter.spec.ts +0 -143
  56. package/intTestV2/tests/locatorRegistry/add/add.frameLocator.spec.ts +0 -23
  57. package/intTestV2/tests/locatorRegistry/add/add.getByAltText.spec.ts +0 -23
  58. package/intTestV2/tests/locatorRegistry/add/add.getById.spec.ts +0 -45
  59. package/intTestV2/tests/locatorRegistry/add/add.getByLabel.spec.ts +0 -23
  60. package/intTestV2/tests/locatorRegistry/add/add.getByPlaceholder.spec.ts +0 -23
  61. package/intTestV2/tests/locatorRegistry/add/add.getByRole.spec.ts +0 -23
  62. package/intTestV2/tests/locatorRegistry/add/add.getByTestId.spec.ts +0 -23
  63. package/intTestV2/tests/locatorRegistry/add/add.getByText.spec.ts +0 -23
  64. package/intTestV2/tests/locatorRegistry/add/add.getByTitle.spec.ts +0 -23
  65. package/intTestV2/tests/locatorRegistry/add/add.locator.spec.ts +0 -23
  66. package/intTestV2/tests/locatorRegistry/add/add.reuseExisting.spec.ts +0 -66
  67. package/intTestV2/tests/locatorRegistry/add/add.reuseReusable.spec.ts +0 -311
  68. package/intTestV2/tests/locatorRegistry/add/add.spec.ts +0 -159
  69. package/intTestV2/tests/locatorRegistry/filter.cycle.spec.ts +0 -39
  70. package/intTestV2/tests/locatorRegistry/getLocator/getLocator.spec.ts +0 -253
  71. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.clearSteps.spec.ts +0 -105
  72. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.describe.spec.ts +0 -23
  73. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.filter.spec.ts +0 -368
  74. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getLocator.spec.ts +0 -56
  75. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getNestedLocator.spec.ts +0 -175
  76. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.nth.spec.ts +0 -60
  77. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.remove.spec.ts +0 -32
  78. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.replace.spec.ts +0 -24
  79. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.spec.ts +0 -110
  80. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.update.spec.ts +0 -322
  81. package/intTestV2/tests/locatorRegistry/getNestedLocator/getNestedLocator.spec.ts +0 -412
  82. package/intTestV2/tests/locatorRegistry/registry/registry.binding.spec.ts +0 -50
  83. package/intTestV2/tests/locatorRegistry/validation/validation.locatorSchemaPath.spec.ts +0 -115
  84. package/intTestV2/tests/locatorRegistry/validation/validation.sub-path.spec.ts +0 -45
  85. package/intTestV2/tests/step/step.spec.ts +0 -49
  86. package/intTestV2/tests/testApp/color.spec.ts +0 -15
  87. package/intTestV2/tests/testApp/iframe.spec.ts +0 -57
  88. package/intTestV2/tests/testApp/testFilters.spec.ts +0 -24
  89. package/intTestV2/tests/testApp/testPage.spec.ts +0 -161
  90. package/intTestV2/tests/testApp/testPath.spec.ts +0 -18
  91. package/pack-build.sh +0 -11
  92. package/pack-test-v2.sh +0 -36
  93. package/playwright.base.ts +0 -42
  94. package/skills/README.md +0 -56
  95. package/skills/pomwright-v1-5-bridge-migration/SKILL.md +0 -40
  96. package/skills/pomwright-v1-5-bridge-migration/references/call-site-migration.md +0 -178
  97. package/skills/pomwright-v1-5-bridge-migration/references/schema-translation.md +0 -183
  98. package/skills/pomwright-v2-migration/SKILL.md +0 -63
  99. package/skills/pomwright-v2-migration/references/call-site-migration.md +0 -265
  100. package/skills/pomwright-v2-migration/references/class-migration.md +0 -266
  101. package/skills/pomwright-v2-migration/references/fixture-and-helpers.md +0 -423
  102. package/skills/pomwright-v2-migration/references/locator-registration.md +0 -344
  103. package/srcV2/fixture/base.fixtures.ts +0 -23
  104. package/srcV2/helpers/navigation.ts +0 -153
  105. package/srcV2/helpers/playwrightReportLogger.ts +0 -196
  106. package/srcV2/helpers/sessionStorage.ts +0 -251
  107. package/srcV2/helpers/stepDecorator.ts +0 -106
  108. package/srcV2/locators/index.ts +0 -15
  109. package/srcV2/locators/locatorQueryBuilder.ts +0 -427
  110. package/srcV2/locators/locatorRegistrationBuilder.ts +0 -558
  111. package/srcV2/locators/locatorRegistry.ts +0 -541
  112. package/srcV2/locators/locatorUpdateBuilder.ts +0 -602
  113. package/srcV2/locators/reusableLocatorBuilder.ts +0 -200
  114. package/srcV2/locators/types.ts +0 -256
  115. package/srcV2/locators/utils.ts +0 -309
  116. package/srcV2/locators/v1SchemaTranslator.ts +0 -178
  117. package/srcV2/pageObject.ts +0 -105
@@ -1,56 +0,0 @@
1
- # PlaywrightReportLogger
2
-
3
- `PlaywrightReportLogger` records log messages during a test and attaches them to Playwright's HTML report. All POMWright fixtures and classes share the same log level and entry list for the duration of a test.
4
-
5
- ## Log levels
6
-
7
- `debug`, `info`, `warn`, `error`
8
-
9
- Changing the level affects every child logger because they reference the same state.
10
-
11
- ## Creating and using loggers
12
-
13
- The `@fixtures/*` test fixtures expose a `log` instance. Child loggers add context to messages without losing shared state:
14
-
15
- ```ts
16
- import { test } from "@fixtures/withoutOptions";
17
-
18
- test("logging", async ({ log }) => {
19
- const pageLog = log.getNewChildLogger("LoginPage");
20
- pageLog.info("filling form");
21
- });
22
- ```
23
-
24
- Inside a Page Object the constructor typically receives the root logger and creates a child:
25
-
26
- ```ts
27
- constructor(page: Page, testInfo: TestInfo, pwrl: PlaywrightReportLogger) {
28
- super(page, testInfo, baseUrl, urlPath, MyPage.name, pwrl);
29
- // this.log is already a child logger for MyPage
30
- }
31
- ```
32
-
33
- ## Attaching to the report
34
-
35
- At the end of each test the fixture calls `attachLogsToTest(testInfo)`. Entries are sorted by timestamp and attached to the Playwright report with the prefix and log level:
36
-
37
- ```text
38
- 20:49:52 05.05.2023 - INFO : [TestCase -> LoginPage] navigating to /login
39
- ```
40
-
41
- You can change verbosity during a test:
42
-
43
- ```ts
44
- log.setLogLevel("debug");
45
- ```
46
-
47
- or temporarily:
48
-
49
- ```ts
50
- const level = log.getCurrentLogLevel();
51
- log.setLogLevel("error");
52
- // ...
53
- log.setLogLevel(level);
54
- ```
55
-
56
- The logger is lightweight but powerful enough to trace locator chains or custom helper behaviour while keeping the information in the final HTML report.
@@ -1,250 +0,0 @@
1
- # Working with Locator Schemas
2
-
3
- `BasePage` exposes two layers of helpers for working with locator schemas:
4
-
5
- 1. **Wrapper shortcuts** – `getLocator()` and `getNestedLocator()` resolve locators in a single call. They are great when you just need a locator and do not have to tweak the schema.
6
- 2. **`getLocatorSchema()` chains** – return a deep copy of the schemas that make up the requested path so you can update selectors, add filters, or reuse the chain with different parameters.
7
-
8
- The sections below show how both approaches fit together.
9
-
10
- ## Example set-up
11
-
12
- The snippets that follow use the simple page object and fixture below.
13
-
14
- ### Create a Page Object Class
15
-
16
- ```ts
17
- import { Page, TestInfo } from "@playwright/test";
18
- import { BasePage, GetByMethod, PlaywrightReportLogger } from "pomwright";
19
-
20
- type LocatorSchemaPath =
21
- | "content"
22
- | "content.heading"
23
- | "content.region.details"
24
- | "content.region.details.button.edit";
25
-
26
- export default class Profile extends BasePage<LocatorSchemaPath> {
27
- constructor(page: Page, testInfo: TestInfo, pwrl: PlaywrightReportLogger) {
28
- super(page, testInfo, "https://someDomain.com", "/profile", Profile.name, pwrl);
29
- }
30
-
31
- protected initLocatorSchemas() {
32
- this.locators.addSchema("content", {
33
- locator: ".main-content",
34
- locatorMethod: GetByMethod.locator
35
- });
36
-
37
- this.locators.addSchema("content.heading", {
38
- role: "heading",
39
- roleOptions: {
40
- name: "Your Profile"
41
- },
42
- locatorMethod: GetByMethod.role
43
- });
44
-
45
- this.locators.addSchema("content.region.details", {
46
- role: "region",
47
- roleOptions: {
48
- name: "Profile Details"
49
- },
50
- locatorMethod: GetByMethod.role
51
- });
52
-
53
- this.locators.addSchema("content.region.details.button.edit", {
54
- role: "button",
55
- roleOptions: {
56
- name: "Edit"
57
- },
58
- locatorMethod: GetByMethod.role
59
- });
60
- }
61
- }
62
- ```
63
-
64
- ### Provide the page object through a fixture
65
-
66
- ```ts
67
- import { test as base } from "pomwright";
68
- import Profile from "./profile";
69
-
70
- type Fixtures = {
71
- profile: Profile;
72
- };
73
-
74
- export const test = base.extend<Fixtures>({
75
- profile: async ({ page, log }, use, testInfo) => {
76
- const profile = new Profile(page, testInfo, log);
77
- await use(profile);
78
- }
79
- });
80
- ```
81
-
82
- ### Use the fixture in a test
83
-
84
- ```ts
85
- import { test } from "./fixtures";
86
-
87
- test("load profile", async ({ profile }) => {
88
- await profile.page.goto(profile.fullUrl);
89
- });
90
- ```
91
-
92
- ## BasePage wrapper shortcuts
93
-
94
- The wrapper methods call `getLocatorSchema(path)` internally and immediately resolve the locator. Use them when the stored schema already matches the element you need.
95
-
96
- ### `getLocator(path)`
97
-
98
- Returns the locator for the final schema in the chain. This is equivalent to `getLocatorSchema(path).getLocator()`.
99
-
100
- ```ts
101
- test("click edit button with a single locator", async ({ profile }) => {
102
- await profile.page.waitForURL(profile.fullUrl);
103
-
104
- const editButton = await profile.getLocator("content.region.details.button.edit");
105
- await editButton.click();
106
- });
107
- ```
108
-
109
- ### `getNestedLocator(path, indices?)`
110
-
111
- Builds a nested locator by chaining every schema that makes up the path. Optional indices let you pick a specific occurrence of any segment.
112
-
113
- ```ts
114
- test("click edit button with a nested locator", async ({ profile }) => {
115
- await profile.page.waitForURL(profile.fullUrl);
116
-
117
- const editButton = await profile.getNestedLocator("content.region.details.button.edit");
118
- await editButton.click();
119
- });
120
- ```
121
-
122
- When a path represents repeating elements, provide sub-path keys to select the right instance:
123
-
124
- ```ts
125
- test("specify index for nested locators", async ({ profile }) => {
126
- await profile.page.waitForURL(profile.fullUrl);
127
-
128
- const editButton = await profile.getNestedLocator(
129
- "content.region.details.button.edit",
130
- {
131
- "content.region.details": 0,
132
- "content.region.details.button.edit": 1
133
- }
134
- );
135
-
136
- await editButton.click();
137
- });
138
- ```
139
-
140
- ## Building chains with `getLocatorSchema()`
141
-
142
- `getLocatorSchema(path)` returns a deep copy of every schema that makes up the `path` plus chainable helpers for refining the locator. All manipulations happen on the copy, so the original definitions inside the page object stay immutable.
143
-
144
- ```ts
145
- const chain = profile.getLocatorSchema("content.region.details.button.edit");
146
- ```
147
-
148
- ### `update(subPath, partial)`
149
-
150
- Override one or more properties of any schema in the chain. Calls can be chained and are applied in order. This is how you adapt selectors to dynamic states without mutating the stored definitions.
151
-
152
- ```ts
153
- const editButton = await profile
154
- .getLocatorSchema("content.region.details.button.edit")
155
- .update("content.region.details.button.edit", {
156
- roleOptions: { name: "Edit details" }
157
- })
158
- .getNestedLocator();
159
- ```
160
-
161
- You can also update intermediate segments without touching the rest of the path:
162
-
163
- ```ts
164
- await profile
165
- .getLocatorSchema("content.region.details.button.edit")
166
- .update("content.region.details", {
167
- locator: ".profile-details",
168
- locatorMethod: GetByMethod.locator
169
- })
170
- .getNestedLocator();
171
- ```
172
-
173
- Chain multiple `update` calls when you need to adjust different LocatorSchema in the chain:
174
-
175
- ```ts
176
- test("make multiple versions of a locator", async ({ profile }) => {
177
- await profile.page.waitForURL(profile.fullUrl);
178
-
179
- const edgeCaseNestedLocator = profile
180
- .getLocatorSchema("content.region.details.button.edit")
181
- .update("content.region.details", {
182
- roleOptions: { name: "Payment Info" }
183
- })
184
- .update("content.region.details.button.edit", {
185
- roleOptions: { name: "Update" }
186
- })
187
- .getNestedLocator();
188
-
189
- await edgeCaseNestedLocator.click();
190
- });
191
- ```
192
-
193
- ### `addFilter(subPath, filterOptions)`
194
-
195
- Adds filters in the same way as Playwright's [`locator.filter()`](https://playwright.dev/docs/api/class-locator#locator-filter). Multiple filters are merged in the order you call them.
196
-
197
- ```ts
198
- const resetButton = await profile
199
- .getLocatorSchema("content.region.details.button.edit")
200
- .addFilter("content.region.details", { hasText: /Profile Details/i })
201
- // .addFilter(...)
202
- .getNestedLocator();
203
- ```
204
-
205
- ### `getNestedLocator(indices?)`
206
-
207
- Resolves the full chain to a Playwright locator. Provide optional indices if you need to target a specific occurrence. This method is the same one the wrapper shortcut delegates to, but it keeps any updates or filters you applied earlier in the chain.
208
-
209
- ```ts
210
- const nestedLocator = await profile
211
- .getLocatorSchema("content.region.details.button.edit")
212
- //.update(...)
213
- //.addFilter(...)
214
- .getNestedLocator({ "content.region": 1 }); // equivalent to .nth(1) (second occurance)
215
- ```
216
-
217
- ### `getLocator()`
218
-
219
- Resolves only the final schema in the chain, i.e. the LocatorSchema which the full LocatorSchemaPath points to. The resulting locator is identical to calling `getNestedLocator()` on a chain that contains a single schema, but it is often more expressive when you only care about the last segment or need to manually chain given some edge case. Same as getNestedLocator, it keeps any updates or filters you applied earlier in the chain.
220
-
221
- ```ts
222
- const badge = await profile
223
- .getLocatorSchema("content.region.details.button.edit")
224
- //.update(...)
225
- //.addFilter(...)
226
- .getLocator();
227
- ```
228
-
229
- ### Reusing a chain
230
-
231
- Because each call to `getLocatorSchema()` returns a deep copy, you can derive multiple locators without affecting the original definitions.
232
-
233
- ```ts
234
- const editButtonSchema = profile.getLocatorSchema("content.region.details.button.edit");
235
-
236
- const editButton = await editButtonSchema.getLocator();
237
- await editButton.click();
238
-
239
- editButtonSchema.update("content.region.details.button.edit", {
240
- roleOptions: { name: "Edit details" }
241
- });
242
-
243
- const editButtonUpdated = await editButtonSchema.getNestedLocator();
244
- await editButtonUpdated.click();
245
-
246
- // Calling profile.getLocatorSchema("content.region.details.button.edit") again
247
- // returns a fresh deep copy of the original schema chain.
248
- ```
249
-
250
- Switching to sub-path keys makes updates easier when `LocatorSchemaPath` strings change, and TypeScript will warn you if you mistype a path. While improving readability.