playwright-ts-automationframework 1.1.73 → 1.1.75

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.
@@ -0,0 +1,365 @@
1
+ # Playwright TS Automation Framework — API Reference
2
+
3
+ Public API exported from `src/index.ts` (published as `playwright-ts-automationframework`, entry `lib/index.js` / `lib/index.d.ts`).
4
+
5
+ Use this document when consuming the package from another solution or as AI context for page objects and tests.
6
+
7
+ ---
8
+
9
+ ## Package import
10
+
11
+ ```typescript
12
+ import {
13
+ BasePage,
14
+ Actions,
15
+ Assertion,
16
+ WebControl,
17
+ Configuration,
18
+ globalSetup,
19
+ globalTearDown,
20
+ logAction,
21
+ logVerification,
22
+ logError,
23
+ logConsole,
24
+ logTestResult,
25
+ } from 'playwright-ts-automationframework';
26
+ ```
27
+
28
+ ### Class hierarchy
29
+
30
+ ```
31
+ BasePage
32
+ └── Actions
33
+ └── Assertion
34
+ ```
35
+
36
+ `Assertion` instances inherit all methods from `Actions` and `BasePage`.
37
+
38
+ ### Playwright config (global hooks)
39
+
40
+ ```typescript
41
+ import { defineConfig } from '@playwright/test';
42
+ import { globalSetup, globalTearDown } from 'playwright-ts-automationframework';
43
+
44
+ export default defineConfig({
45
+ globalSetup,
46
+ globalTeardown: globalTearDown,
47
+ });
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Standalone exports
53
+
54
+ | Export | Signature | Description |
55
+ |--------|-----------|-------------|
56
+ | `globalSetup` | `(config: FullConfig) => Promise<void>` | Clears execution log file before run |
57
+ | `globalTearDown` | `(config: FullConfig) => Promise<void>` | Sends execution result email after run |
58
+ | `logAction` | `(message: string) => void` | Log UI action (console + file) |
59
+ | `logVerification` | `(message: string) => void` | Log verification message |
60
+ | `logError` | `(message: string) => void` | Log error |
61
+ | `logConsole` | `(message: string) => void` | Log info to console |
62
+ | `logTestResult` | `(message: string) => void` | Log test start/end banners |
63
+
64
+ ---
65
+
66
+ ## WebControl
67
+
68
+ Wraps a Playwright `Locator` with a human-readable description for logging.
69
+
70
+ ### Constructor
71
+
72
+ ```typescript
73
+ new WebControl(controlLocator: Locator, controlDescription: string)
74
+ ```
75
+
76
+ ### Properties
77
+
78
+ | Property | Type | Description |
79
+ |----------|------|-------------|
80
+ | `controlLocator` | `Locator` | Playwright locator |
81
+ | `controlDescription` | `string` | Label used in logs (e.g. `'Login button'`) |
82
+
83
+ ### Example
84
+
85
+ ```typescript
86
+ const loginBtn = new WebControl(page.locator('#login'), 'Login button');
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Configuration (static)
92
+
93
+ Reads/writes `AppConfigurations.json` and `ExecutionSettings.json` (paths resolved relative to consumer project layout).
94
+
95
+ ### Static fields
96
+
97
+ | Field | Type | Default | Description |
98
+ |-------|------|---------|-------------|
99
+ | `Environment` | `string` | `"QA"` | Environment key when not overridden by settings |
100
+ | `EmailRecievers` | `string` | `";"` | Fallback email recipients |
101
+ | `SenderEmail` | `string` | `";"` | Fallback sender email |
102
+ | `SenderPassword` | `string` | `";"` | Fallback sender password |
103
+
104
+ ### Static getters
105
+
106
+ | Getter | Returns | Description |
107
+ |--------|---------|-------------|
108
+ | `environment` | `string` | From `ExecutionSettings.json` or `Configuration.Environment` |
109
+ | `emailRecievers` | `string` | From settings or static fallback |
110
+ | `senderEmail` | `string` | From settings |
111
+ | `senderPassword` | `string` | From settings |
112
+ | `configurationData` | `JSON` | Environment block from `AppConfigurations.json` |
113
+
114
+ ### Static methods
115
+
116
+ | Method | Signature | Description |
117
+ |--------|-----------|-------------|
118
+ | `get` | `(key: string) => any` | Read config value for current environment |
119
+ | `set` | `(key: string, value: any) => void` | Set value and persist to `AppConfigurations.json` |
120
+
121
+ ### Example
122
+
123
+ ```typescript
124
+ const url = Configuration.get('URL');
125
+ Configuration.set('URL', 'https://example.com');
126
+ ```
127
+
128
+ ---
129
+
130
+ ## BasePage
131
+
132
+ Browser initialization and test lifecycle logging.
133
+
134
+ ### Constructor
135
+
136
+ ```typescript
137
+ constructor(page: Page)
138
+ ```
139
+
140
+ ### Instance methods
141
+
142
+ | Method | Signature | Description |
143
+ |--------|-----------|-------------|
144
+ | `initializeBrowser` | `(url?: string) => Promise<void>` | Navigate to URL (default: `Configuration.get("URL")`), 60s timeout, `waitUntil: "load"` |
145
+
146
+ ### Static methods
147
+
148
+ | Method | Signature | Description |
149
+ |--------|-----------|-------------|
150
+ | `setTestCaseID` | `(testInfo: TestInfo) => void` | Log test start banner |
151
+ | `executionCompleted` | `(testInfo: TestInfo) => void` | Log test end banner with status |
152
+
153
+ ### Example
154
+
155
+ ```typescript
156
+ const pageObj = new BasePage(page);
157
+ await pageObj.initializeBrowser();
158
+
159
+ BasePage.setTestCaseID(test.info);
160
+ BasePage.executionCompleted(test.info);
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Actions (extends BasePage)
166
+
167
+ Logged wrappers around common Playwright interactions. All methods take `WebControl` unless noted.
168
+
169
+ ### Constructor
170
+
171
+ ```typescript
172
+ constructor(page: Page)
173
+ ```
174
+
175
+ ### Interaction
176
+
177
+ | Method | Signature | Description |
178
+ |--------|-----------|-------------|
179
+ | `click` | `(control, isforceful?: boolean) => Promise<void>` | Click element (`force` when `isforceful` is true) |
180
+ | `mouseHover` | `(control) => Promise<void>` | Hover over element |
181
+ | `focusAndPressKeyboardEvent` | `(control, action: string) => Promise<void>` | Focus then press key |
182
+ | `type` | `(control, textTobeEntered: string) => Promise<void>` | Fill text (logged) |
183
+ | `typePassword` | `(control, textTobeEntered: string) => Promise<void>` | Fill password (logged as `********`) |
184
+ | `pressKeyboardEvent` | `(control, key: string) => Promise<void>` | Press key on element |
185
+ | `selectFromDropdownByValue` | `(control, optionTobeSelcted: string) => Promise<void>` | `selectOption({ value })` |
186
+ | `selectFromDropdownByText` | `(control, optionTobeSelcted: string) => Promise<void>` | `selectOption({ label })` |
187
+ | `selectFromDropdownByPartialText` | `(control, partialText: string) => Promise<void>` | Select first option containing partial text |
188
+ | `selectFromDropdownByIndex` | `(control, index: number) => Promise<void>` | `selectOption({ index })` |
189
+ | `selectCheckbox` | `(control, expectedCheckboxValue?: boolean) => Promise<void>` | Check/uncheck (default: checked) |
190
+ | `scrollToControl` | `(control) => Promise<void>` | `scrollIntoViewIfNeeded` |
191
+ | `navigateBack` | `() => Promise<void>` | Browser back |
192
+ | `handleAlert` | `(action: string) => Promise<void>` | Register dialog handler; `"accept"` accepts, else dismiss |
193
+ | `closeBrowser` | `() => Promise<void>` | Close page |
194
+
195
+ ### Read / state
196
+
197
+ | Method | Signature | Returns | Description |
198
+ |--------|-----------|---------|-------------|
199
+ | `isSelected` | `(control)` | `Promise<boolean>` | Checkbox/radio checked state |
200
+ | `isEnabled` | `(control)` | `Promise<boolean>` | Enabled state |
201
+ | `isDisplayed` | `(control)` | `Promise<boolean>` | Visible state |
202
+ | `getText` | `(control)` | `Promise<string>` | `innerText` |
203
+ | `getTextboxValue` | `(control)` | `Promise<string>` | `inputValue` |
204
+ | `getInputValue` | `(control)` | `Promise<string>` | `inputValue` |
205
+ | `getSelectedItemFromDropdown` | `(control)` | `Promise<string>` | Selected dropdown value (`inputValue`) |
206
+ | `getAttributeValue` | `(control, attributeName: string)` | `Promise<string \| null>` | Attribute value |
207
+ | `findAll` | `(control)` | `Promise<Locator[]>` | All matching locators (waits for present) |
208
+ | `getAllInnerText` | `(control)` | `Promise<string[]>` | All `innerText` values |
209
+ | `getAllTextContents` | `(control)` | `Promise<string[]>` | All `textContent` values |
210
+ | `getURL` | `()` | `Promise<string>` | Current page URL |
211
+ | `getTitle` | `()` | `Promise<string>` | Page title |
212
+ | `getAlertDialogMessage` | `()` | `Promise<...>` | Dialog message via handler |
213
+
214
+ ### Waits / navigation
215
+
216
+ | Method | Signature | Description |
217
+ |--------|-----------|-------------|
218
+ | `waitTillPageURLContains` | `(url: string, timeoutInSeconds?: number) => Promise<...>` | `waitForURL` (default timeout 60s) |
219
+ | `waitTillElementIsPresent` | `(control, timeoutInSeconds?: number) => Promise<void>` | Wait visible (default 60s) |
220
+ | `waitTillElementIsEnabled` | `(control, timeoutInSeconds?: number) => Promise<void>` | Wait enabled (default 60s) |
221
+ | `waitTillElementIsAttached` | `(control, timeoutInSeconds?: number) => Promise<void>` | Wait attached in DOM (default 60s) |
222
+ | `waitTillElementIsNotPresent` | `(control, timeoutInSeconds?: number) => Promise<void>` | Wait hidden (default 60s) |
223
+ | `sleep` | `(timeInSeconds?: number) => Promise<void>` | Fixed delay (default 5s) |
224
+ | `waitForPageTimeout` | `(timeoutInSeconds?: number) => Promise<void>` | `page.waitForTimeout` (default 5s) |
225
+ | `waitForPageLoad` | `(timeInSeconds?: number) => Promise<void>` | `load` state (default 30s) |
226
+ | `waitForPageDOMcontentLoaded` | `(timeInSeconds?: number) => Promise<void>` | `domcontentloaded` (default 30s) |
227
+ | `waitForNetworkIdle` | `(timeInSeconds?: number) => Promise<void>` | `networkidle` (default 30s) |
228
+ | `refreshWebPage` | `(timeInSeconds?: number) => Promise<void>` | Reload page (default 30s) |
229
+
230
+ ---
231
+
232
+ ## Assertion (extends Actions)
233
+
234
+ Verification helpers using Playwright `expect.soft` and framework logging.
235
+
236
+ ### Constructor
237
+
238
+ ```typescript
239
+ constructor(page: Page)
240
+ ```
241
+
242
+ ### Generic comparisons
243
+
244
+ | Method | Signature | Description |
245
+ |--------|-----------|-------------|
246
+ | `verifyIsEquals` | `(object1: any, object2: any, controlDescription?: string) => void` | Strict equality |
247
+ | `verifyIsNotEquals` | `(object1: any, object2: any, controlDescription?: string) => void` | Not equal |
248
+ | `verifyIsEqualIgnorecase` | `(object1, object2, controlDescription?, caseInsensitive?: boolean) => void` | Equal; optional case-insensitive for strings |
249
+ | `verifyIsContains` | `(actual: string \| string[], expected: string, controlDescription?: string) => void` | String or array contains substring |
250
+
251
+ ### Element state
252
+
253
+ | Method | Signature | Description |
254
+ |--------|-----------|-------------|
255
+ | `verifyIsDisplayed` | `(control, expectedIsDisplayed?: boolean) => Promise<void>` | Visible/hidden (default: displayed) |
256
+ | `verifyIsNotDisplayed` | `(control, isAlreadyHidden?: boolean) => Promise<void>` | Element is hidden |
257
+ | `verifyIsEnabled` | `(control, expValue?: boolean) => Promise<void>` | Enabled (default true); else calls `verifyIsDisabled` |
258
+ | `verifyIsDisabled` | `(control, expValue?: boolean) => Promise<void>` | Disabled |
259
+ | `verifyIsSelected` | `(control, expValue?: boolean) => Promise<void>` | Checkbox/radio selected |
260
+ | `verifyCheckboxValue` | `(control, value: boolean) => Promise<void>` | Checkbox matches expected |
261
+ | `verifyTagName` | `(control, expectedTagName: string) => Promise<void>` | Tag name (case-insensitive) |
262
+
263
+ ### Text and attributes
264
+
265
+ | Method | Signature | Description |
266
+ |--------|-----------|-------------|
267
+ | `verifyAttributeValue` | `(control, attributeName, expectedAttributeValue) => Promise<void>` | Attribute equals |
268
+ | `verifyAttributeValueContains` | `(control, attributeName, attributeValue) => Promise<void>` | Attribute contains |
269
+ | `verifyDisplayedText` | `(control, expectedText) => Promise<void>` | `innerText` equals |
270
+ | `verifyDisplayedTextContains` | `(control, expectedText) => Promise<void>` | `innerText` contains |
271
+ | `verifyDisplayedTextDoesNotContains` | `(control, expectedText) => Promise<void>` | `innerText` does not contain |
272
+ | `verifyTextboxValue` | `(control, expectedText) => Promise<void>` | `value` attribute equals |
273
+ | `verifyTextboxValueContains` | `(control, expectedText) => Promise<void>` | `value` attribute contains |
274
+ | `verifyInnerText` | `(control, expectedText) => Promise<void>` | `innerText` equals |
275
+ | `verifyInnerTextContains` | `(control, expectedText) => Promise<void>` | `innerText` contains |
276
+ | `verifyInputValue` | `(control, expectedText) => Promise<void>` | `inputValue` equals |
277
+ | `verifyInputValueContains` | `(control, expectedText) => Promise<void>` | `inputValue` contains |
278
+
279
+ ### Lists and counts
280
+
281
+ | Method | Signature | Description |
282
+ |--------|-----------|-------------|
283
+ | `verifyListContainsValue` | `(control, valueToVerify: string) => Promise<void>` | At least one list item contains value |
284
+ | `verifyListContainsMultipleValues` | `(control, listOfValueToVerify: string[], waitTillElementIsDisplayed?) => Promise<void>` | Each value present in list |
285
+ | `verifyDropdownOptions` | `(control, listOfValueToVerify: string[], waitTillElementIsDisplayed?) => Promise<void>` | Dropdown options contain values |
286
+ | `verifyListForMultipleValues` | `(control, listOfValueToVerify: string[], waitTillElementIsDisplayed?) => Promise<void>` | Index-aligned list text match |
287
+ | `verifyCountOfElements` | `(control, expectedCount: number) => Promise<void>` | Locator count equals |
288
+ | `verifyCountOfElementsIsGreaterOrEqual` | `(control, expectedCount: number) => Promise<void>` | Count >= expected |
289
+ | `verifyCountOfElementsIsLesseOrEqual` | `(control, expectedCount: number) => Promise<void>` | Count <= expected |
290
+
291
+ ### Page and alert
292
+
293
+ | Method | Signature | Description |
294
+ |--------|-----------|-------------|
295
+ | `verifyAlertText` | `(expectedText: string) => Promise<void>` | Alert message contains text |
296
+ | `verifyURLContains` | `(subString: string) => Promise<void>` | Current URL contains substring |
297
+ | `verifyPageTitleContains` | `(expectedText: string) => Promise<void>` | Page title contains text |
298
+
299
+ ---
300
+
301
+ ## Recommended usage patterns
302
+
303
+ ### Page object extending Assertion
304
+
305
+ ```typescript
306
+ import { Page } from '@playwright/test';
307
+ import { Assertion, WebControl } from 'playwright-ts-automationframework';
308
+
309
+ export class LoginPage extends Assertion {
310
+ private readonly username = new WebControl(
311
+ page.locator('#username'),
312
+ 'Username textbox'
313
+ );
314
+
315
+ constructor(page: Page) {
316
+ super(page);
317
+ }
318
+
319
+ async login(user: string, pass: string) {
320
+ await this.type(this.username, user);
321
+ // ...
322
+ }
323
+ }
324
+ ```
325
+
326
+ ### Test hooks
327
+
328
+ ```typescript
329
+ import { test } from '@playwright/test';
330
+ import { BasePage } from 'playwright-ts-automationframework';
331
+
332
+ test.beforeEach(async ({}, testInfo) => {
333
+ BasePage.setTestCaseID(testInfo);
334
+ });
335
+
336
+ test.afterEach(async ({}, testInfo) => {
337
+ BasePage.executionCompleted(testInfo);
338
+ });
339
+ ```
340
+
341
+ ---
342
+
343
+ ## Not part of the public API
344
+
345
+ The following exist in the repo but are **not** exported from `src/index.ts`:
346
+
347
+ | Symbol | Location | Notes |
348
+ |--------|----------|-------|
349
+ | `SendEmail` | `src/core/sendEmail.ts` | Used internally by `globalTearDown` only |
350
+
351
+ ---
352
+
353
+ ## Export summary
354
+
355
+ | Category | Count |
356
+ |----------|-------|
357
+ | Standalone functions | 7 |
358
+ | Exported classes | 5 (`BasePage`, `Actions`, `Assertion`, `WebControl`, `Configuration`) |
359
+ | `BasePage` public methods | 3 (+ constructor) |
360
+ | `Actions` public methods | 38 (+ constructor) |
361
+ | `Assertion` public methods | 35 (+ constructor) |
362
+ | `WebControl` | constructor + 2 properties |
363
+ | `Configuration` | 4 fields + 5 getters + `get` / `set` |
364
+
365
+ **Version:** See `package.json` → `"version"` (e.g. `1.1.74` at time of writing).
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Playwright Typescript Automation framework library
2
2
 
3
+ ## API Reference
4
+
5
+ Full list of Actions, Assertions, WebControl, Configuration, and logging APIs: [API-REFERENCE.md](./API-REFERENCE.md)
6
+
7
+ After `npm install`, the same file is available at `node_modules/playwright-ts-automationframework/API-REFERENCE.md`.
8
+
3
9
  Sample Project: https://github.com/ketanp88/PlaywrightFrameworkDemoProject
4
10
 
5
11
  Playwright Typescript Automation framework
@@ -313,6 +313,19 @@ export declare class Actions extends BasePage {
313
313
  * waitTillElementIsPresent(usernameTxtbx);
314
314
  */
315
315
  waitTillElementIsPresent(control: WebControl, timeoutInSeconds?: number): Promise<void>;
316
+ /**
317
+ * Wait till element is enabled
318
+ *
319
+ * @param control Wait for element to be enabled.
320
+ * @param timeoutInSeconds Timeout in seconds (default 60).
321
+ *
322
+ * Example:
323
+ *
324
+ * uploadBtn = new WebControl(this.page.getByRole('button', { name: 'Upload files' }), 'Upload files button');
325
+ *
326
+ * waitTillElementIsEnabled(uploadBtn);
327
+ */
328
+ waitTillElementIsEnabled(control: WebControl, timeoutInSeconds?: number): Promise<void>;
316
329
  /**
317
330
  * Wait till element is attached to the dom
318
331
  *
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Actions = void 0;
4
+ const test_1 = require("@playwright/test");
4
5
  const basePage_core_1 = require("./basePage.core");
5
6
  const logs_core_1 = require("./logs.core");
6
7
  /**
@@ -631,6 +632,27 @@ class Actions extends basePage_core_1.BasePage {
631
632
  (0, logs_core_1.logError)(`❌ waitTillElementIsPresent failed for '${control.controlDescription}' (visible, ${timeoutInSeconds}s) due to reason: '${error}'`);
632
633
  }
633
634
  }
635
+ /**
636
+ * Wait till element is enabled
637
+ *
638
+ * @param control Wait for element to be enabled.
639
+ * @param timeoutInSeconds Timeout in seconds (default 60).
640
+ *
641
+ * Example:
642
+ *
643
+ * uploadBtn = new WebControl(this.page.getByRole('button', { name: 'Upload files' }), 'Upload files button');
644
+ *
645
+ * waitTillElementIsEnabled(uploadBtn);
646
+ */
647
+ async waitTillElementIsEnabled(control, timeoutInSeconds = 60) {
648
+ try {
649
+ await this.page.waitForLoadState("domcontentloaded");
650
+ await (0, test_1.expect)(control.controlLocator.first()).toBeEnabled({ timeout: timeoutInSeconds * 1000 });
651
+ }
652
+ catch (error) {
653
+ (0, logs_core_1.logError)(`❌ waitTillElementIsEnabled failed for '${control.controlDescription}' (enabled, ${timeoutInSeconds}s) due to reason: '${error}'`);
654
+ }
655
+ }
634
656
  /**
635
657
  * Wait till element is attached to the dom
636
658
  *
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "playwright-ts-automationframework",
3
- "version": "1.1.73",
4
- "description": "",
3
+ "version": "1.1.75",
4
+ "description": "Playwright TypeScript automation framework with Actions, Assertions, and WebControl wrappers",
5
+ "homepage": "https://github.com/ketanp88/playwright-TS-AutomationFramework/blob/main/API-REFERENCE.md",
5
6
  "main": "lib/index.js",
6
7
  "types": "lib/index.d.ts",
7
8
  "scripts": {
@@ -19,15 +20,17 @@
19
20
  "ignore-case": "^0.1.0"
20
21
  },
21
22
  "dependencies": {
22
- "@playwright/test": "^1.59.1",
23
- "@types/node": "^25.6.0",
23
+ "@playwright/test": "^1.60.0",
24
+ "@types/node": "^25.7.0",
24
25
  "log4js": "^6.9.1",
25
26
  "nodemailer": "^8.0.7",
26
- "npm": "^11.13.0",
27
+ "npm": "^11.14.1",
27
28
  "path": "^0.12.7",
28
29
  "typescript": "^6.0.3"
29
30
  },
30
31
  "files": [
31
- "lib/**/**"
32
+ "lib/**/**",
33
+ "README.md",
34
+ "API-REFERENCE.md"
32
35
  ]
33
36
  }